Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/ontology/adapters/nice.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/ontology/adapters/nice.go |
| Original SHA-256 | 9891ce2ea6e0a03598db9136ec13cff7de59353405ca6532738b41cfb75f5ada |
| Git blob SHA | 2f54233fb14fc95eae219797e9f19af87907be69 |
| Reading-copy SHA-256 | 9891ce2ea6e0a03598db9136ec13cff7de59353405ca6532738b41cfb75f5ada |
Every recorded occurrence
These 20 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/ontology/adapters/nice.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws6-retrieval | 6c56e29231ec05735927fa265c97d517499dfeaf | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws1-ontology-sync | b596f449a32a1016fbd403c36505cc00a1ac9ee6 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws3-clearance | 4b8e7ce594c068621867f9c9deed0ec64ae6c553 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | phase2-eval-fairness | d361af254701975fe239927656ababb56374655e | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws2-alias-relationship | e4dada4601c6eb101830f9d223a9655dfa120616 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/ontology/adapters/nice.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓167 lines · 5.1 KB
package adapters
import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"time"
"github.com/missionworkforce/missionmatch/internal/modules/ontology"
)
// NICESource ingests the NIST NICE Workforce Framework for Cybersecurity (SP 800-181 Rev 1)
// components JSON published by the NIST Cybersecurity and Privacy Reference Tool (CPRT).
// It yields one KindWorkRole record per work_role element and one KindKSA record per task,
// knowledge, or skill element. Structural element types (sort, category, competency_area,
// opm_code) are skipped.
type NICESource struct {
url string
client *http.Client
}
// NewNICESource builds the adapter. url is the NICE components JSON location published by NIST CPRT.
func NewNICESource(url string, client *http.Client) *NICESource {
if client == nil {
client = &http.Client{Timeout: 120 * time.Second}
}
return &NICESource{url: url, client: client}
}
// Name is the provenance label stamped on every record this source yields.
func (s *NICESource) Name() string { return "NICE Framework" }
// Fetch downloads the NICE components JSON and yields one record per work role and TKS element.
func (s *NICESource) Fetch(ctx context.Context, yield func(ontology.VocabRecord) error) error {
data, err := s.download(ctx)
if err != nil {
return err
}
recs, err := parseNICE(data)
if err != nil {
return err
}
for _, r := range recs {
if err := yield(r); err != nil {
return err
}
}
return nil
}
func (s *NICESource) download(ctx context.Context) ([]byte, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, s.url, nil)
if err != nil {
return nil, fmt.Errorf("nice: new request: %w", err)
}
resp, err := s.client.Do(req)
if err != nil {
return nil, fmt.Errorf("nice: get: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("nice: provider returned %s", resp.Status)
}
return io.ReadAll(resp.Body)
}
// niceDocument mirrors the top-level shape of the NIST CPRT NICE components JSON
// (v2-2-0_nf_components.json, confirmed from the live file at
// https://csrc.nist.gov/csrc/media/Projects/cprt/documents/nice/v2-2-0_nf_components.json).
type niceDocument struct {
Elements []niceElement `json:"elements"`
}
// niceElement mirrors one entry in the elements array. The five fields below are the complete
// set present in the real file; element_type values observed are: sort, category, competency_area,
// opm_code, work_role, task, knowledge, skill.
type niceElement struct {
ElementType string `json:"element_type"`
ElementIdentifier string `json:"element_identifier"`
Title string `json:"title"`
Text string `json:"text"`
DocIdentifier string `json:"doc_identifier"`
}
// parseNICE decodes NICE components JSON bytes and returns one VocabRecord per work_role and
// per TKS (task, knowledge, skill) element. All other element types are skipped.
//
// Schema notes confirmed from the live v2-2-0 file:
//
// work_role: identifier in element_identifier (e.g. OG-WRL-017), name in title, description in text.
// task: identifier in element_identifier (e.g. T0006), title is empty, description in text.
// knowledge: identifier in element_identifier (e.g. K0018), title is empty, description in text.
// skill: identifier in element_identifier (e.g. S0011), title is empty, description in text.
func parseNICE(data []byte) ([]ontology.VocabRecord, error) {
var doc niceDocument
if err := json.Unmarshal(data, &doc); err != nil {
return nil, fmt.Errorf("nice: decode JSON: %w", err)
}
out := make([]ontology.VocabRecord, 0, len(doc.Elements))
for _, el := range doc.Elements {
id := strings.TrimSpace(el.ElementIdentifier)
if id == "" {
continue
}
switch el.ElementType {
case "work_role":
term := strings.TrimSpace(el.Title)
if term == "" {
term = strings.TrimSpace(el.Text)
}
if term == "" {
continue
}
raw, _ := json.Marshal(map[string]string{
"element_type": el.ElementType,
"element_identifier": id,
"title": el.Title,
"text": el.Text,
})
out = append(out, ontology.VocabRecord{
SourceName: "NICE Framework",
SourceRecordID: id,
Kind: ontology.KindWorkRole,
Term: term,
Code: id,
Category: el.ElementType,
Description: strings.TrimSpace(el.Text),
Raw: raw,
})
case "task", "knowledge", "skill":
term := strings.TrimSpace(el.Text)
if term == "" {
term = strings.TrimSpace(el.Title)
}
if term == "" {
continue
}
raw, _ := json.Marshal(map[string]string{
"element_type": el.ElementType,
"element_identifier": id,
"title": el.Title,
"text": el.Text,
})
out = append(out, ontology.VocabRecord{
SourceName: "NICE Framework",
SourceRecordID: id,
Kind: ontology.KindKSA,
Term: term,
Code: id,
Category: el.ElementType,
Description: term,
Raw: raw,
})
default:
// sort, category, competency_area, opm_code and any future structural types are skipped.
}
}
return out, nil
}