Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/matching/engine/types.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/matching/engine/types.go |
| Original SHA-256 | a958eaa75afc4c7077573a4e4e6e72a4a403db2858c38deef5e99caa5608a39f |
| Git blob SHA | c765db4185d62920780da2423cb617bde209cc12 |
| Reading-copy SHA-256 | a958eaa75afc4c7077573a4e4e6e72a4a403db2858c38deef5e99caa5608a39f |
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/types.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/matching/engine/types.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓233 lines · 8.1 KB
// Package engine is the PURE, deterministic missionMATCH scoring core.
//
// It is the product's core IP and a compliance asset (an Automated Employment Decision Tool),
// so it is held to three hard rules from CLAUDE.md:
//
// 1. PURE: no database, no I/O, no clock, no randomness. The skill matcher is INJECTED.
// 2. DETERMINISTIC: all scoring math is decimal (never float64) and every input order is
// normalized, so the same inputs always yield byte-identical scores and explanations.
// 3. FAIR + EXPLAINABLE: it never reads a demographic/EEO attribute or a proxy for one, and
// every score carries a per-component breakdown, a human-readable rationale, a gap summary,
// and the matched required→candidate skill pairs with their similarity (the decision trace).
//
// Fixed weights (CLAUDE.md, do NOT change without explicit instruction):
//
// Clearance .25 Skills .25 Certifications .15 CustomerExperience .15 Experience .10 Location .10
package engine
import (
"context"
"github.com/shopspring/decimal"
)
// ---------- Clearance model ----------
// ClearanceLevel is the ordered US personnel-security hierarchy. Higher ordinal satisfies lower
// (TS/SCI satisfies Secret; Secret does NOT satisfy TS/SCI). Unknown is the safe default zero.
type ClearanceLevel int
const (
ClearanceUnknown ClearanceLevel = iota // missing/unparseable, scores 0
ClearanceNone // no clearance / public trust
ClearanceConfidential
ClearanceSecret
ClearanceTopSecret
ClearanceTSSCI // Top Secret with SCI access
)
func (c ClearanceLevel) String() string {
switch c {
case ClearanceNone:
return "None"
case ClearanceConfidential:
return "Confidential"
case ClearanceSecret:
return "Secret"
case ClearanceTopSecret:
return "Top Secret"
case ClearanceTSSCI:
return "TS/SCI"
default:
return "Unknown"
}
}
// Polygraph is an additional access gate layered on a clearance. Full-scope satisfies CI.
type Polygraph int
const (
PolyNone Polygraph = iota
PolyCI // counterintelligence
PolyFullScope // full-scope / lifestyle (satisfies CI)
)
func (p Polygraph) String() string {
switch p {
case PolyCI:
return "CI Poly"
case PolyFullScope:
return "Full Scope Poly"
default:
return "No Poly"
}
}
// ClearanceStatus gates the clearance: only an Active clearance can score. Expired/Unknown = 0.
type ClearanceStatus int
const (
StatusUnknown ClearanceStatus = iota
StatusActive
StatusExpired
StatusInactive
)
// Clearance is a candidate's held clearance (or a requirement's required clearance via RequiredLevel/RequiredPoly).
type Clearance struct {
Level ClearanceLevel
Poly Polygraph
Status ClearanceStatus
Compartments []string // SCI control systems or SAP markers the candidate holds; nil and empty are both "none"
}
// ---------- Candidate & Requirement (pure value inputs, NOT the DB models) ----------
// CandidateSkill is a single skill on a candidate, already normalized to the ontology upstream.
// SkillID is the ontology id (stable); Name is the display label. The engine compares by SkillID
// for exact matches and defers to the injected SkillMatcher for semantic matches.
type CandidateSkill struct {
SkillID string
Name string
}
// Candidate is the pure scoring input for one person. It deliberately contains NO demographic field.
type Candidate struct {
ID string
Clearance Clearance
Skills []CandidateSkill
Certifications []string // normalized cert names
CustomerExperience []string // government customers/agencies the candidate has supported
YearsExperience int
Location string
Remote bool // candidate can/will work remotely
Relocatable bool
Available bool // available to staff now
}
// RequiredSkill is a skill a requirement demands. Mandatory drives the gap summary (an unmet
// mandatory skill is a hard gap); a non-mandatory required skill still counts toward the skill score.
type RequiredSkill struct {
SkillID string
Name string
Mandatory bool
}
// Requirement is the pure scoring input for one role/labor-category.
type Requirement struct {
ID string
RequiredLevel ClearanceLevel
RequiredPoly Polygraph
RequiredSkills []RequiredSkill
RequiredCerts []string
CustomerAgency string // "" means no specific customer required
RequiredYears int
WorkLocation string
RemoteAllowed bool
KeyPersonnel bool // a Key Personnel slot (surfaced; does not alter the score)
RequiredCompartments []string // compartments the candidate must hold; nil and empty mean no compartment requirement
}
// ---------- Skill matching (INJECTED, keeps the engine pure & testable) ----------
// SkillMatch records that a required skill was satisfied by a candidate skill, and how.
type SkillMatch struct {
RequiredSkillID string
RequiredSkillName string
CandidateSkillID string // "" when unmatched
CandidateName string
Similarity decimal.Decimal // 1.0 for an exact match; the cosine similarity for a semantic match
Exact bool
AliasMatched bool // flags a match that came from a curated alias rather than an exact name or id match, for audit
Matched bool
}
// SkillMatcher resolves a required skill against a candidate's skills: exact first, then semantic.
// It is injected so the engine has no embedding/DB dependency and tests are fully deterministic.
// Implementations MUST be deterministic for a given input. Threshold is the engine's semantic cutoff.
type SkillMatcher interface {
// Match returns the best candidate skill satisfying the required skill at or above threshold.
// On an exact id/name match it returns Exact=true, Similarity=1.0. ok is false when nothing
// meets the threshold. ctx carries the request deadline and cancellation to any provider call.
Match(ctx context.Context, required RequiredSkill, candidateSkills []CandidateSkill, threshold decimal.Decimal) (m SkillMatch, ok bool)
}
// ---------- Result ----------
// Band is the proposal-readiness classification of a total score.
type Band int
const (
BandRed Band = iota // Recruiting Required (< 75)
BandYellow // Potential (75–89.99)
BandGreen // Proposal Ready (>= 90)
)
func (b Band) String() string {
switch b {
case BandGreen:
return "Green"
case BandYellow:
return "Yellow"
default:
return "Red"
}
}
// Label is the human-facing band name used in slates and explanations.
func (b Band) Label() string {
switch b {
case BandGreen:
return "Proposal Ready"
case BandYellow:
return "Potential"
default:
return "Recruiting Required"
}
}
// ComponentScore is one weighted row of the decision trace (the AEDT/explainability artifact).
type ComponentScore struct {
Component string // "Clearance", "Skills", ...
Weight decimal.Decimal // 0.25, 0.15, ...
Raw decimal.Decimal // the 0–100 sub-score
Weighted decimal.Decimal // Raw * Weight (contribution to the total)
Rationale string // human-readable reason for the sub-score
}
// MatchResult is the full, explainable, reproducible outcome of scoring one candidate vs one requirement.
type MatchResult struct {
CandidateID string
RequirementID string
Clearance decimal.Decimal
Skills decimal.Decimal
Certifications decimal.Decimal
CustomerExperience decimal.Decimal
Experience decimal.Decimal
Location decimal.Decimal
Total decimal.Decimal // 0–100, rounded to 2 dp
Band Band
Explanation string // a human-readable summary
GapSummary []string // unmet MANDATORY items (clearance, mandatory skills, required certs, ...)
MatchedSkills []SkillMatch // required→candidate pairs with similarity (and the unmatched ones)
Trace []ComponentScore // per-component weighted breakdown, the decision trace
// WeightProfileVersion names the weight set that produced this result, stamped by the caller
// (the matching service): the tenant AIOE profile version when one is active, otherwise
// GlobalDefaultProfileVersion. The engine itself never reads it.
WeightProfileVersion string
}