diff --git a/apps/nextpath/README.md b/apps/nextpath/README.md index f82e411..33e493b 100644 --- a/apps/nextpath/README.md +++ b/apps/nextpath/README.md @@ -10,8 +10,10 @@ four kinds of evidence without pretending they are interchangeable: 4. Arizona labor-market outlook and recent example job postings. The product does not calculate a person's probability of being hired. It -publishes a transparent **Arizona Opportunity Score** whose market components, -dates, geography, and sources remain visible beside the recommendation. +publishes a transparent **Arizona employability outlook percentage** comparing +annual graduates, projected annual openings, and current entry-level postings. +Raw counts, dates, geography, sources, and limitations remain visible beside +the percentage. See [the architecture document](../../docs/nextpath-architecture.md) for the MVP boundaries and delivery slices. diff --git a/cmd/nextpath/internal/opportunity/outlook.go b/cmd/nextpath/internal/opportunity/outlook.go new file mode 100644 index 0000000..57176f7 --- /dev/null +++ b/cmd/nextpath/internal/opportunity/outlook.go @@ -0,0 +1,103 @@ +// Package opportunity calculates transparent labor-market signals. It does +// not predict whether an individual will be hired. +package opportunity + +import ( + "errors" + "math" + "time" +) + +const FormulaVersion = "az-employability-outlook-v1" + +var ErrInsufficientEvidence = errors.New("insufficient evidence for employability outlook") + +type Evidence struct { + ArizonaAnnualGraduates int `json:"arizona_annual_graduates"` + ArizonaProjectedOpenings int `json:"arizona_projected_annual_openings"` + ActiveEntryLevelPostings int `json:"active_entry_level_postings"` + GraduateAcademicYear string `json:"graduate_academic_year"` + ProjectionPeriod string `json:"projection_period"` + PostingsObservedAt time.Time `json:"postings_observed_at"` + Geography string `json:"geography"` + SOCToCIPMappingCoverage float64 `json:"soc_to_cip_mapping_coverage"` + GraduateSourceURL string `json:"graduate_source_url"` + ProjectionSourceURL string `json:"projection_source_url"` + PostingSourceURL string `json:"posting_source_url"` +} + +type Outlook struct { + FormulaVersion string `json:"formula_version"` + EmployabilityOutlookPercent int `json:"employability_outlook_percent"` + AnnualDemandCoveragePercent int `json:"annual_demand_coverage_percent"` + LivePostingCoveragePercent int `json:"live_posting_coverage_percent"` + AnnualDemandToGraduateRatio float64 `json:"annual_demand_to_graduate_ratio"` + Label string `json:"label"` + Confidence string `json:"confidence"` + Limitations []string `json:"limitations"` + Evidence Evidence `json:"evidence"` +} + +// Calculate uses projected annual openings for the stable 75-percent signal +// and a current entry-level posting snapshot for the remaining 25 percent. +// The result is market context, not a personal hiring probability. +func Calculate(evidence Evidence) (Outlook, error) { + if evidence.ArizonaAnnualGraduates <= 0 || evidence.ArizonaProjectedOpenings < 0 || evidence.ActiveEntryLevelPostings < 0 { + return Outlook{}, ErrInsufficientEvidence + } + if evidence.GraduateAcademicYear == "" || evidence.ProjectionPeriod == "" || evidence.PostingsObservedAt.IsZero() || evidence.Geography == "" { + return Outlook{}, ErrInsufficientEvidence + } + if evidence.GraduateSourceURL == "" || evidence.ProjectionSourceURL == "" || evidence.PostingSourceURL == "" { + return Outlook{}, ErrInsufficientEvidence + } + if evidence.SOCToCIPMappingCoverage <= 0 || evidence.SOCToCIPMappingCoverage > 1 { + return Outlook{}, ErrInsufficientEvidence + } + + annualRatio := float64(evidence.ArizonaProjectedOpenings) / float64(evidence.ArizonaAnnualGraduates) + liveRatio := float64(evidence.ActiveEntryLevelPostings) / float64(evidence.ArizonaAnnualGraduates) + annualCoverage := cappedPercent(annualRatio) + liveCoverage := cappedPercent(liveRatio) + outlookPercent := int(math.Round(float64(annualCoverage)*0.75 + float64(liveCoverage)*0.25)) + + confidence := "lower" + if evidence.SOCToCIPMappingCoverage >= 0.8 { + confidence = "higher" + } else if evidence.SOCToCIPMappingCoverage >= 0.5 { + confidence = "moderate" + } + + return Outlook{ + FormulaVersion: FormulaVersion, + EmployabilityOutlookPercent: outlookPercent, + AnnualDemandCoveragePercent: annualCoverage, + LivePostingCoveragePercent: liveCoverage, + AnnualDemandToGraduateRatio: math.Round(annualRatio*100) / 100, + Label: outlookLabel(outlookPercent), + Confidence: confidence, + Limitations: []string{ + "Rough market estimate—not your chance of being hired.", + "Current postings are a changing snapshot and may contain incomplete entry-level labels.", + "Graduates may enter other occupations, and workers may enter without a mapped Arizona program.", + }, + Evidence: evidence, + }, nil +} + +func cappedPercent(ratio float64) int { + return int(math.Round(math.Min(1, math.Max(0, ratio)) * 100)) +} + +func outlookLabel(percent int) string { + switch { + case percent >= 80: + return "strong demand relative to recent graduates" + case percent >= 50: + return "moderate demand relative to recent graduates" + case percent >= 25: + return "competitive market" + default: + return "limited visible demand relative to recent graduates" + } +} diff --git a/cmd/nextpath/internal/opportunity/outlook_test.go b/cmd/nextpath/internal/opportunity/outlook_test.go new file mode 100644 index 0000000..1799d65 --- /dev/null +++ b/cmd/nextpath/internal/opportunity/outlook_test.go @@ -0,0 +1,62 @@ +package opportunity + +import ( + "errors" + "testing" + "time" +) + +func completeEvidence() Evidence { + return Evidence{ + ArizonaAnnualGraduates: 1000, ArizonaProjectedOpenings: 800, + ActiveEntryLevelPostings: 200, GraduateAcademicYear: "2024-25", + ProjectionPeriod: "2024-2034", PostingsObservedAt: time.Date(2026, 12, 5, 12, 0, 0, 0, time.UTC), + Geography: "Arizona", SOCToCIPMappingCoverage: 0.9, + GraduateSourceURL: "https://example.test/graduates", ProjectionSourceURL: "https://example.test/projections", + PostingSourceURL: "https://example.test/postings", + } +} + +func TestCalculateShowsTransparentBoundedOutlook(t *testing.T) { + outlook, err := Calculate(completeEvidence()) + if err != nil { + t.Fatal(err) + } + if outlook.EmployabilityOutlookPercent != 65 { + t.Fatalf("outlook = %d, want 65", outlook.EmployabilityOutlookPercent) + } + if outlook.AnnualDemandCoveragePercent != 80 || outlook.LivePostingCoveragePercent != 20 { + t.Fatalf("unexpected components: %+v", outlook) + } + if outlook.AnnualDemandToGraduateRatio != 0.8 || outlook.Confidence != "higher" { + t.Fatalf("unexpected ratio/confidence: %+v", outlook) + } + if len(outlook.Limitations) == 0 { + t.Fatal("outlook omitted limitations") + } +} + +func TestDemandAboveGraduatesRetainsUncappedRatio(t *testing.T) { + evidence := completeEvidence() + evidence.ArizonaProjectedOpenings = 2400 + evidence.ActiveEntryLevelPostings = 1500 + outlook, err := Calculate(evidence) + if err != nil { + t.Fatal(err) + } + if outlook.EmployabilityOutlookPercent != 100 || outlook.AnnualDemandToGraduateRatio != 2.4 { + t.Fatalf("unexpected shortage signal: %+v", outlook) + } +} + +func TestCalculateRefusesMissingOrMisleadingEvidence(t *testing.T) { + cases := []Evidence{completeEvidence(), completeEvidence(), completeEvidence()} + cases[0].ArizonaAnnualGraduates = 0 + cases[1].PostingsObservedAt = time.Time{} + cases[2].SOCToCIPMappingCoverage = 0 + for index, evidence := range cases { + if _, err := Calculate(evidence); !errors.Is(err, ErrInsufficientEvidence) { + t.Fatalf("case %d error = %v, want ErrInsufficientEvidence", index, err) + } + } +} diff --git a/docs/nextpath-architecture.md b/docs/nextpath-architecture.md index 915f607..807a380 100644 --- a/docs/nextpath-architecture.md +++ b/docs/nextpath-architecture.md @@ -8,8 +8,8 @@ NextPath helps a person answer three separate questions: - Which Arizona education or training paths can move me toward that work? - What does current public evidence say about demand for that occupation? -It is an exploration and planning tool, not a psychological diagnosis, hiring -prediction, or replacement for a school or career counselor. +It is an exploration and planning tool, not a psychological diagnosis, +guarantee of employment, or replacement for a school or career counselor. ## MVP users @@ -31,7 +31,8 @@ neither requested nor stored. Accounts can be exported and deleted. ## Evidence model NextPath keeps personal fit and market opportunity as independent dimensions. -A career card must never turn them into a purported hiring probability. +A career card may show a market **employability outlook percentage**, but must +not describe it as the person's probability of being hired. ### Personal fit @@ -49,22 +50,29 @@ The question bank, scoring version, and answer scale are versioned. Later adaptive questions may clarify preferences, but must not silently modify the validated scoring formula. -### Arizona Opportunity Score +### Arizona employability outlook -The initial zero-to-100 score is deterministic and reports each component: +The initial zero-to-100 percentage is a transparent market comparison. It +answers, approximately, "how much Arizona demand is visible relative to the +number of people completing relevant programs?" It does not account for an +individual's grades, experience, interview performance, network, work +authorization, or employer decisions. | Component | Weight | Evidence | | --- | ---: | --- | -| Projected growth | 25 | Arizona employment projections | -| Annual openings | 25 | Arizona employment projections | -| Current demand | 20 | Fresh, deduplicated public job listings | -| Wage position | 15 | Arizona or metro occupational wages | -| Training access | 15 | Nearby programs and registered apprenticeships | +| Annual demand coverage | 75 | Projected annual Arizona openings divided by annual Arizona completers | +| Live posting coverage | 25 | Current deduplicated entry-level postings divided by annual Arizona completers | -Each component includes its observation date, geography, source URL, and a -confidence value. Missing evidence lowers confidence instead of being treated -as zero. The UI must say "opportunity score," never "employability rate" or -"chance of getting hired." +Each coverage value is capped at 100 before weighting. The UI also shows the +uncapped annual openings-to-graduates ratio, so a shortage is not hidden when +demand exceeds supply. Current postings are a volatile snapshot and influence +only 25 percent of the result. The application displays all three raw counts: +annual graduates, projected annual openings, and active postings today. + +Each component includes its observation date, geography, source URL, mapping +coverage, and confidence value. Missing evidence makes the percentage +unavailable instead of silently becoming zero. The UI must label it "rough +market estimate—not your chance of being hired." ## Data contracts @@ -126,7 +134,7 @@ replace it before a broader pilot. 2. Versioned RIASEC assessment kernel with deterministic tests. 3. Registration, sessions, assessment UI, save, export, and deletion. 4. Versioned occupation catalog and personal-fit ranking. -5. Arizona public-data ingestion and transparent opportunity scoring. +5. Arizona public-data ingestion and transparent employability outlook. 6. Nearby education, CTE, and apprenticeship matching. 7. Fresh example job listings with deduplication and source links. 8. Career comparison and what-if planning.