Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/matching/intelligence/intelligence.go |
| Original SHA-256 | 6ff216e68c76cd33e151419396be54af09ffd261b3b8ac6dfc07b1b2442c59d2 |
| Git blob SHA | d329a4fd71cf752b092359c7220b4622e4657b46 |
| Reading-copy SHA-256 | 6ff216e68c76cd33e151419396be54af09ffd261b3b8ac6dfc07b1b2442c59d2 |
Every recorded occurrence
These 35 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/intelligence/intelligence.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | per-tenant-routing | 9bde0f9a74b89d01980fa658e5253acda7528d0c | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws6-retrieval | 6c56e29231ec05735927fa265c97d517499dfeaf | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-a-shared-core | e0de03ac3a1ec826bd15d0e048e3b02baa23eeff | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-c-slatematch | 5cd60c918301b46ecd6ed3e03e20c395da0062e2 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws1-ontology-sync | b596f449a32a1016fbd403c36505cc00a1ac9ee6 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | w3-ai-staffing-recommendations | 43d56387270ef4da4cabd794d97ca6a49909bc7d | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws3-clearance | 4b8e7ce594c068621867f9c9deed0ec64ae6c553 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-d-command-center | 255e7d1d420abf5e277d0cd8c9b14f6f72b6acb9 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | phase2-eval-fairness | d361af254701975fe239927656ababb56374655e | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-e-dataflow-deploy | 433815a042f9741411e60fa553fe72143e9b10db | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ruthless-debug-sweep | b7d742f8f032984be3817efffa3eb8b13b651c1f | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ai-intelligence-layer | 5d5ddff70393a197c5f54a45280bb5dd42b24755 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-a-opportunity-intelligence | 1675031db74316e100782d063e9eda1a597fe3a1 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | deploy-and-ops | bdacd9d0b4d5998d25fc74bf4007f4c3ec538c7a | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws2-alias-relationship | e4dada4601c6eb101830f9d223a9655dfa120616 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-b-screenmatch | 09015496d565a172bcaa15cfe9a8e4b072b13df0 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-e-commercial-stubs | 4437da660539284a400ee380b9b427a300c369ee | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | ai-brain-live | aac32fc49c878cc5bca099459307611562d0bac1 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-d-missionmatch | 3be46ba89edb737182075a2b320509b42dc916f8 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | workstream-b-sam-contract-awards | d5101cceb98e70000cebb31d3e7ac73d747d3a6d | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/matching/intelligence/intelligence.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓391 lines · 14.2 KB
// Package intelligence derives the customer-facing screenMATCH™ "Mission Readiness" panels from the
// pure engine output. It is PURE (no DB/IO/clock except an explicit asOf passed in) and adds NO new
// scoring, every panel is a presentation/derivation of the same deterministic MatchResult, so the
// AEDT explainability and reproducibility guarantees carry through unchanged.
//
// Panels (from the "Defining missionMATCH/screenMATCH" brief + screenMATCH User Guide):
// - MissionReadiness : the centerpiece, operational status + the 6 named readiness categories.
// - NextSteps : recommended actions from the band/gaps.
// - BattleCard : strengths/gaps scouting view.
// - ClearanceIntel : clearance intelligence layer (eligibility, investigation age, recency).
// - ContractReadiness: satisfied requirement areas + risk areas.
// - WinImpact : proposal-staffing win impact + reasons.
package intelligence
import (
"fmt"
"strings"
"time"
"github.com/shopspring/decimal"
"github.com/missionworkforce/missionmatch/internal/modules/matching/engine"
)
var hundredVal = decimal.NewFromInt(100)
// ---------- Mission Readiness (the centerpiece) ----------
// MissionReadiness rebadges the engine result into operational language.
type MissionReadiness struct {
Status string `json:"status"` // "Mission Ready" | "Review Required" | "Recruiting Required"
StatusCode string `json:"status_code"` // "ready" | "review" | "recruiting"
Score string `json:"score"` // "92.00"
Band string `json:"band"` // green | yellow | red
Categories []ReadinessCategory `json:"categories"`
}
// ReadinessCategory is one named readiness dimension (the User Guide §8 breakdown).
type ReadinessCategory struct {
Name string `json:"name"` // "Clearance Readiness"
Score string `json:"score"` // "100.00"
Weight string `json:"weight"` // "0.25"
State string `json:"state"` // "ready" (>=90) | "partial" (75-89) | "gap" (<75)
}
// engine Trace component name -> operational readiness label.
var categoryLabels = map[string]string{
"Clearance": "Clearance Readiness",
"Skills": "Skills Readiness",
"Certifications": "Certification Readiness",
"CustomerExperience": "Customer Readiness",
"Experience": "Experience Readiness",
"LocationAvailability": "Availability Readiness",
}
// Readiness builds the Mission Readiness panel from a match result.
func Readiness(res engine.MatchResult) MissionReadiness {
cats := make([]ReadinessCategory, 0, len(res.Trace))
for _, c := range res.Trace {
name := categoryLabels[c.Component]
if name == "" {
name = c.Component
}
cats = append(cats, ReadinessCategory{
Name: name,
Score: c.Raw.StringFixed(2),
Weight: c.Weight.String(),
State: stateFor(c.Raw),
})
}
status, code := missionStatus(res.Band)
return MissionReadiness{
Status: status, StatusCode: code, Score: res.Total.StringFixed(2),
Band: res.Band.Code(), Categories: cats,
}
}
// MissionStatusLabel is the operational status label for a band ("Mission Ready", etc.).
func MissionStatusLabel(b engine.Band) string { l, _ := missionStatus(b); return l }
func missionStatus(b engine.Band) (label, code string) {
switch b {
case engine.BandGreen:
return "Mission Ready", "ready"
case engine.BandYellow:
return "Review Required", "review"
default:
return "Recruiting Required", "recruiting"
}
}
// stateFor classifies a 0-100 sub-score using the same band thresholds as the total.
func stateFor(score decimal.Decimal) string {
switch {
case score.GreaterThanOrEqual(engine.BandGreenMin):
return "ready"
case score.GreaterThanOrEqual(engine.BandYellowMin):
return "partial"
default:
return "gap"
}
}
// ---------- Recommended Next Steps ----------
// NextStep is a recommended action shown after evaluation.
type NextStep struct {
Action string `json:"action"`
Reason string `json:"reason"`
}
// NextSteps recommends actions from the band (User Guide §12).
func NextSteps(res engine.MatchResult) []NextStep {
switch res.Band {
case engine.BandGreen:
return []NextStep{
{"Move to Candidate Slate", "Candidate is proposal ready."},
{"Add to Talent Pipeline", "Retain for future opportunities."},
}
case engine.BandYellow:
return []NextStep{
{"Request Interview", "Additional validation recommended."},
{"Review Gaps", "Resolve gaps before submission."},
{"Add to Talent Pipeline", "Suitable for future opportunities."},
}
default:
return []NextStep{
{"Recruit Additional Candidates", "Qualification gaps identified."},
{"Add to Talent Pipeline", "Reconsider for better-fit opportunities."},
}
}
}
// ---------- Battle Card ----------
// BattleCard is the scouting-report view (User Guide §9).
type BattleCard struct {
Strengths []string `json:"strengths"`
Gaps []string `json:"gaps"`
}
// BattleCardFor derives strengths (✓) and gaps (⚠) from the candidate + result.
func BattleCardFor(c engine.Candidate, r engine.Requirement, res engine.MatchResult) BattleCard {
var strengths []string
if res.Clearance.GreaterThanOrEqual(hundredVal) && c.Clearance.Level >= engine.ClearanceConfidential {
strengths = append(strengths, fmt.Sprintf("%s %s", c.Clearance.Level.String(), c.Clearance.Status.String()))
}
for _, m := range res.MatchedSkills {
if m.Matched {
strengths = append(strengths, m.RequiredSkillName)
}
}
if res.CustomerExperience.GreaterThanOrEqual(hundredVal) && r.CustomerAgency != "" {
strengths = append(strengths, fmt.Sprintf("%s experience", r.CustomerAgency))
}
if r.RequiredYears > 0 && c.YearsExperience >= r.RequiredYears {
strengths = append(strengths, fmt.Sprintf("Exceeds experience requirement (%d yrs)", c.YearsExperience))
}
// Held certifications that the requirement asked for.
held := lowerSet(c.Certifications)
for _, rc := range r.RequiredCerts {
if held[lower(rc)] {
strengths = append(strengths, rc)
}
}
gaps := append([]string{}, res.GapSummary...) // unmet mandatory items (empty slice, never null)
return BattleCard{Strengths: dedupe(strengths), Gaps: gaps}
}
// ---------- Clearance Intelligence ----------
// ClearanceFacts is the clearance input (carries dates the engine deliberately omits).
type ClearanceFacts struct {
Level engine.ClearanceLevel
Poly engine.Polygraph
Status engine.ClearanceStatus
GrantedAt *time.Time
ExpiresAt *time.Time
ReinvestigationDueAt *time.Time
CustomerAgencies []string
// Provenance records HOW the clearance is known (self_reported is the default and honest baseline);
// the platform never verifies a clearance itself. VerifiedAt is set when an FSO or sponsor confirmed.
Provenance string
VerifiedAt *time.Time
}
// ClearanceIntel is the clearance intelligence layer (Evolution #6).
type ClearanceIntel struct {
Current string `json:"current"` // "TS/SCI"
Status string `json:"status"` // "Active"
SCIEligible bool `json:"sci_eligible"` // TS or above
CIPolyEligible bool `json:"ci_poly_eligible"`
FullScopePoly bool `json:"full_scope_poly"`
Expired bool `json:"expired"`
InvestigationAgeMonths *int `json:"investigation_age_months,omitempty"`
ExpiresAt *string `json:"expires_at,omitempty"`
ReinvestigationDueAt *string `json:"reinvestigation_due_at,omitempty"`
RecentClassifiedSupport bool `json:"recent_classified_support"`
// Provenance and honesty: the platform never verifies a clearance, it records how the clearance is
// known. Verified is true ONLY when an FSO or sponsor confirmed it (the authoritative DISS check),
// never because the platform checked. The default self_reported reads "self reported, not verified".
Provenance string `json:"provenance"` // self_reported | sponsor_verified | document | continuous_vetting
ProvenanceLabel string `json:"provenance_label"` // human label
Verified bool `json:"verified"` // true only for a sponsor FSO verification
VerifiedAt *string `json:"verified_at,omitempty"`
}
// provenanceLabel maps a clearance provenance code to honest UI copy. Self reported is never "verified".
func provenanceLabel(p string) string {
switch p {
case "sponsor_verified":
return "Sponsor FSO verified"
case "document":
return "Document on file, not FSO verified"
case "continuous_vetting":
return "Continuous vetting enrolled"
default:
return "Self reported, not verified"
}
}
// Clearance derives the clearance intelligence as-of a date.
func Clearance(f ClearanceFacts, asOf time.Time) ClearanceIntel {
ci := ClearanceIntel{
Current: f.Level.String(),
Status: f.Status.String(),
SCIEligible: f.Level >= engine.ClearanceTopSecret,
CIPolyEligible: f.Poly >= engine.PolyCI,
FullScopePoly: f.Poly == engine.PolyFullScope,
RecentClassifiedSupport: len(f.CustomerAgencies) > 0,
}
if f.ExpiresAt != nil {
ci.Expired = f.ExpiresAt.Before(asOf)
s := f.ExpiresAt.Format("2006-01-02")
ci.ExpiresAt = &s
}
if f.Status == engine.StatusExpired {
ci.Expired = true
}
if f.ReinvestigationDueAt != nil {
s := f.ReinvestigationDueAt.Format("2006-01-02")
ci.ReinvestigationDueAt = &s
}
if f.GrantedAt != nil {
m := monthsBetween(*f.GrantedAt, asOf)
ci.InvestigationAgeMonths = &m
}
prov := f.Provenance
if prov == "" {
prov = "self_reported"
}
ci.Provenance = prov
ci.ProvenanceLabel = provenanceLabel(prov)
ci.Verified = prov == "sponsor_verified" // only an FSO confirmation counts as verified, never the platform
if f.VerifiedAt != nil {
s := f.VerifiedAt.Format("2006-01-02")
ci.VerifiedAt = &s
}
return ci
}
// ---------- Contract Readiness ----------
// RequirementArea is one contract requirement category and whether the candidate satisfies it.
type RequirementArea struct {
Area string `json:"area"`
Met bool `json:"met"`
}
// RiskArea is a flagged staffing risk.
type RiskArea struct {
Severity string `json:"severity"` // "warning" | "info"
Message string `json:"message"`
}
// ContractReadiness lists satisfied requirement areas + risk areas (Evolution #3).
type ContractReadiness struct {
Areas []RequirementArea `json:"areas"`
Risks []RiskArea `json:"risks"`
}
// Contract derives contract readiness. expiringWindow is how soon a clearance expiry is a risk.
func Contract(c engine.Candidate, r engine.Requirement, res engine.MatchResult, f ClearanceFacts, asOf time.Time) ContractReadiness {
areas := []RequirementArea{
{"Labor Category Requirements", res.Skills.GreaterThanOrEqual(engine.BandYellowMin)},
{"Clearance Requirements", res.Clearance.GreaterThanOrEqual(hundredVal)},
{"Certification Requirements", res.Certifications.GreaterThanOrEqual(hundredVal)},
{"Customer Experience Requirements", res.CustomerExperience.GreaterThanOrEqual(hundredVal)},
{"Availability Requirements", res.Location.GreaterThanOrEqual(engine.BandGreenMin)},
}
risks := []RiskArea{} // empty slice, never null
if f.ExpiresAt != nil {
days := int(f.ExpiresAt.Sub(asOf).Hours() / 24)
switch {
case days < 0:
risks = append(risks, RiskArea{"warning", "Clearance is expired."})
case days <= 90:
risks = append(risks, RiskArea{"warning", fmt.Sprintf("Clearance expires in %d days.", days)})
}
}
if len(f.CustomerAgencies) == 0 {
risks = append(risks, RiskArea{"warning", "No recorded classified/customer program support."})
}
if r.RequiredYears > 0 && c.YearsExperience < r.RequiredYears {
risks = append(risks, RiskArea{"info", fmt.Sprintf("Experience below requirement (%d of %d years).", c.YearsExperience, r.RequiredYears)})
}
if f.ReinvestigationDueAt != nil && f.ReinvestigationDueAt.Before(asOf) {
risks = append(risks, RiskArea{"warning", "Periodic reinvestigation is overdue."})
}
return ContractReadiness{Areas: areas, Risks: risks}
}
// ---------- Win Impact ----------
// WinImpact is the proposal-staffing win impact (Evolution #2).
type WinImpact struct {
Level string `json:"level"` // "High Impact" | "Medium Impact" | "Low Impact"
LevelCode string `json:"level_code"` // high | medium | low
StaffingStrength string `json:"staffing_strength"` // "92.00"
Reasons []string `json:"reasons"`
}
// Win derives the win impact + reasons.
func Win(c engine.Candidate, r engine.Requirement, res engine.MatchResult) WinImpact {
// A non nil empty slice so JSON encodes [] not null when nothing fires; the client maps over it.
reasons := []string{}
if c.Clearance.Level == engine.ClearanceTSSCI && c.Clearance.Status == engine.StatusActive {
reasons = append(reasons, "Active TS/SCI")
}
if res.CustomerExperience.GreaterThanOrEqual(hundredVal) && r.CustomerAgency != "" {
reasons = append(reasons, fmt.Sprintf("Prior %s / similar program experience", r.CustomerAgency))
}
if r.KeyPersonnel && res.Band == engine.BandGreen {
reasons = append(reasons, "Matches Key Personnel requirements")
}
if r.RequiredYears > 0 && c.YearsExperience > r.RequiredYears {
reasons = append(reasons, "Exceeds required experience")
}
if res.Clearance.GreaterThanOrEqual(hundredVal) {
reasons = append(reasons, "Meets clearance requirement")
}
level, code := "Low Impact", "low"
switch res.Band {
case engine.BandGreen:
level, code = "High Impact", "high"
case engine.BandYellow:
level, code = "Medium Impact", "medium"
}
return WinImpact{Level: level, LevelCode: code, StaffingStrength: res.Total.StringFixed(2), Reasons: reasons}
}
// ---------- helpers ----------
// monthsBetween returns whole calendar months from a to b (>= 0).
func monthsBetween(a, b time.Time) int {
m := int(b.Year()-a.Year())*12 + int(b.Month()) - int(a.Month())
if b.Day() < a.Day() {
m--
}
if m < 0 {
m = 0
}
return m
}
func lower(s string) string { return strings.ToLower(strings.TrimSpace(s)) }
func lowerSet(items []string) map[string]bool {
m := make(map[string]bool, len(items))
for _, it := range items {
m[lower(it)] = true
}
return m
}
func dedupe(items []string) []string {
seen := make(map[string]bool, len(items))
out := make([]string, 0, len(items))
for _, it := range items {
if !seen[it] {
seen[it] = true
out = append(out, it)
}
}
return out
}