Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/platform/missionclass/missionclass.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/platform/missionclass/missionclass.go |
| Original SHA-256 | 0d4708ffcb79cfe99d254354af377020f8e339bf927486aa52ac72681f95c18b |
| Git blob SHA | ba519d2208e3a8d64ce9acfeb0df9813535b1d24 |
| Reading-copy SHA-256 | 0d4708ffcb79cfe99d254354af377020f8e339bf927486aa52ac72681f95c18b |
Every recorded occurrence
These 15 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/platform/missionclass/missionclass.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/platform/missionclass/missionclass.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓127 lines · 4.5 KB
// Package missionclass is the pure deterministic mission and labor classifier. It tags federal record
// text with structured mission areas (the missionclass.Codes vocabulary) using a keyword gazetteer, the
// WS2 alias layer, and a curated PSC and NAICS crosswalk, each inference carrying the mechanism and the
// evidence phrase so every tag is traceable. The package is pure: no clock, no randomness, no network,
// and no DB, so its output is byte stable for fixed input. Mission tags are NEVER a scoring input and
// never reference the eeo schema.
package missionclass
import (
"regexp"
"sort"
"strings"
)
// Mechanism records HOW a mission was inferred, so every tag is traceable (the WS7 acceptance criterion).
const (
MechKeyword = "keyword"
MechAlias = "alias"
MechPSC = "psc"
MechNAICS = "naics"
)
// Hit is one mission inference with its provenance.
type Hit struct {
Code string
Mechanism string
Evidence string // the matched phrase or code
}
type form struct {
code string
re *regexp.Regexp
text string // canonical evidence phrase for this form
}
// wbForm compiles a case insensitive, word boundary anchored matcher for a phrase. Any single space in a
// multi word phrase becomes \s+, so a line break or a double space between tokens still matches. The
// phrase is regex quoted, so a literal containing a metacharacter is matched safely.
func wbForm(code, phrase string) form {
return form{code: code, text: phrase,
re: regexp.MustCompile(`(?i)\b` + strings.ReplaceAll(regexp.QuoteMeta(phrase), " ", `\s+`) + `\b`)}
}
// missionForms is iterated in Codes order. Keep in sync with ai/mission.go missionVocabulary.
var missionForms = []form{
wbForm("SIGINT", "sigint"), wbForm("SIGINT", "signals intelligence"),
wbForm("GEOINT", "geoint"), wbForm("GEOINT", "geospatial intelligence"),
wbForm("HUMINT", "humint"), wbForm("HUMINT", "human intelligence"),
wbForm("MASINT", "masint"), wbForm("MASINT", "measurement and signature intelligence"),
wbForm("OSINT", "osint"), wbForm("OSINT", "open source intelligence"),
wbForm("SAT_C2", "satellite c2"), wbForm("SAT_C2", "satellite command and control"),
wbForm("CDS", "cross domain solution"), wbForm("CDS", "cross domain solutions"),
wbForm("COMSEC", "comsec"), wbForm("COMSEC", "communications security"),
wbForm("TEMPEST", "tempest"),
wbForm("EW", "electronic warfare"),
}
// ClassifyKeyword returns one Hit per mission code whose keyword form appears in text, in Codes order.
func ClassifyKeyword(text string) []Hit {
if strings.TrimSpace(text) == "" {
return nil
}
found := map[string]Hit{}
for _, f := range missionForms {
if _, ok := found[f.code]; ok {
continue
}
if f.re.MatchString(text) {
found[f.code] = Hit{Code: f.code, Mechanism: MechKeyword, Evidence: f.text}
}
}
return ordered(found)
}
// AliasIndex maps a lowercased mission bearing phrase to a mission code. It is built from the curated WS2
// alias rows and the category 'mission_area' skills, so the alias layer (not a cosine threshold) carries
// acronym and synonym knowledge. Phrases are matched on a word boundary, whitespace tolerant.
type AliasIndex struct {
forms []form
}
// NewAliasIndex builds an AliasIndex from a phrase to code map. The forms are appended in sorted key
// order so the build is deterministic and the resulting index iterates the same way every run.
func NewAliasIndex(phraseToCode map[string]string) AliasIndex {
keys := make([]string, 0, len(phraseToCode))
for k := range phraseToCode {
keys = append(keys, k)
}
sort.Strings(keys) // deterministic build order
ai := AliasIndex{}
for _, k := range keys {
ai.forms = append(ai.forms, wbForm(phraseToCode[k], k))
}
return ai
}
// ClassifyAlias returns one Hit per mission code whose alias phrase appears in text, in Codes order.
func ClassifyAlias(text string, idx AliasIndex) []Hit {
if strings.TrimSpace(text) == "" {
return nil
}
found := map[string]Hit{}
for _, f := range idx.forms {
if _, ok := found[f.code]; ok {
continue
}
if f.re.MatchString(text) {
found[f.code] = Hit{Code: f.code, Mechanism: MechAlias, Evidence: f.text}
}
}
return ordered(found)
}
// ordered returns the hits sorted by the canonical Codes order, for byte stable output.
func ordered(m map[string]Hit) []Hit {
rank := map[string]int{}
for i, c := range Codes {
rank[c] = i
}
out := make([]Hit, 0, len(m))
for _, h := range m {
out = append(out, h)
}
sort.Slice(out, func(i, j int) bool { return rank[out[i].Code] < rank[out[j].Code] })
return out
}