diff --git a/apps/nextpath/README.md b/apps/nextpath/README.md index c25bda7..f1fc7cf 100644 --- a/apps/nextpath/README.md +++ b/apps/nextpath/README.md @@ -11,7 +11,7 @@ four kinds of evidence without pretending they are interchangeable: The product does not calculate a person's probability of being hired. It publishes a transparent **Arizona employability outlook percentage** comparing -annual graduates, projected annual openings, and current entry-level postings. +annual completions, projected annual openings, and current occupation postings. Raw counts, dates, geography, sources, and limitations remain visible beside the percentage. @@ -33,3 +33,23 @@ Redeployments never recreate the account store. Jeannie migrates the original manual-preview file from `/data/homelab-nextpath/accounts.json` when needed and writes a mode-0600 pre-deploy backup under `/data/homelab-nextpath/backups`. +## Enable the Arizona employability outlook + +College Scorecard completion data is public. Projected openings and current +postings use the official CareerOneStop API, which requires a free API user ID +and token. Supply them only for the first deployment (or when rotating them): + +```bash +read -r -p "CareerOneStop user ID: " career_user +read -r -s -p "CareerOneStop API token: " career_token; echo +LAB_NEXTPATH_CAREERONESTOP_USER_ID="$career_user" \ +LAB_NEXTPATH_CAREERONESTOP_API_TOKEN="$career_token" \ + ./jeannie deploy-nextpath +unset career_user career_token +``` + +Jeannie stores the values in private mode-0600 files, refreshes evidence once +immediately, and installs a daily systemd timer. Later deployments reuse the +private credentials and the last successful evidence snapshot. Neither values +nor raw source responses are exposed to browsers. + diff --git a/cmd/nextpath/internal/opportunity/outlook.go b/cmd/nextpath/internal/opportunity/outlook.go index 57176f7..a09fc38 100644 --- a/cmd/nextpath/internal/opportunity/outlook.go +++ b/cmd/nextpath/internal/opportunity/outlook.go @@ -15,7 +15,7 @@ var ErrInsufficientEvidence = errors.New("insufficient evidence for employabilit type Evidence struct { ArizonaAnnualGraduates int `json:"arizona_annual_graduates"` ArizonaProjectedOpenings int `json:"arizona_projected_annual_openings"` - ActiveEntryLevelPostings int `json:"active_entry_level_postings"` + ActivePostings int `json:"active_postings"` GraduateAcademicYear string `json:"graduate_academic_year"` ProjectionPeriod string `json:"projection_period"` PostingsObservedAt time.Time `json:"postings_observed_at"` @@ -39,10 +39,10 @@ type Outlook struct { } // Calculate uses projected annual openings for the stable 75-percent signal -// and a current entry-level posting snapshot for the remaining 25 percent. +// and a current occupation 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 { + if evidence.ArizonaAnnualGraduates <= 0 || evidence.ArizonaProjectedOpenings < 0 || evidence.ActivePostings < 0 { return Outlook{}, ErrInsufficientEvidence } if evidence.GraduateAcademicYear == "" || evidence.ProjectionPeriod == "" || evidence.PostingsObservedAt.IsZero() || evidence.Geography == "" { @@ -56,7 +56,7 @@ func Calculate(evidence Evidence) (Outlook, error) { } annualRatio := float64(evidence.ArizonaProjectedOpenings) / float64(evidence.ArizonaAnnualGraduates) - liveRatio := float64(evidence.ActiveEntryLevelPostings) / float64(evidence.ArizonaAnnualGraduates) + liveRatio := float64(evidence.ActivePostings) / float64(evidence.ArizonaAnnualGraduates) annualCoverage := cappedPercent(annualRatio) liveCoverage := cappedPercent(liveRatio) outlookPercent := int(math.Round(float64(annualCoverage)*0.75 + float64(liveCoverage)*0.25)) @@ -78,7 +78,7 @@ func Calculate(evidence Evidence) (Outlook, error) { 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.", + "Current postings are a changing snapshot and include varying experience levels.", "Graduates may enter other occupations, and workers may enter without a mapped Arizona program.", }, Evidence: evidence, diff --git a/cmd/nextpath/internal/opportunity/outlook_test.go b/cmd/nextpath/internal/opportunity/outlook_test.go index 1799d65..9203e09 100644 --- a/cmd/nextpath/internal/opportunity/outlook_test.go +++ b/cmd/nextpath/internal/opportunity/outlook_test.go @@ -9,7 +9,7 @@ import ( func completeEvidence() Evidence { return Evidence{ ArizonaAnnualGraduates: 1000, ArizonaProjectedOpenings: 800, - ActiveEntryLevelPostings: 200, GraduateAcademicYear: "2024-25", + ActivePostings: 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", @@ -39,7 +39,7 @@ func TestCalculateShowsTransparentBoundedOutlook(t *testing.T) { func TestDemandAboveGraduatesRetainsUncappedRatio(t *testing.T) { evidence := completeEvidence() evidence.ArizonaProjectedOpenings = 2400 - evidence.ActiveEntryLevelPostings = 1500 + evidence.ActivePostings = 1500 outlook, err := Calculate(evidence) if err != nil { t.Fatal(err) diff --git a/cmd/nextpath/internal/web/server_test.go b/cmd/nextpath/internal/web/server_test.go index d7b05e3..3b4c82d 100644 --- a/cmd/nextpath/internal/web/server_test.go +++ b/cmd/nextpath/internal/web/server_test.go @@ -26,7 +26,7 @@ func TestCompletePrivateAssessmentFlow(t *testing.T) { opportunityPath := filepath.Join(t.TempDir(), "opportunity.json") if err := os.WriteFile(opportunityPath, []byte(`{ "version":"v1","generated_at":"2026-12-05T12:00:00Z","occupations":{"13-2011.00":{ - "arizona_annual_graduates":100,"arizona_projected_annual_openings":100,"active_entry_level_postings":50, + "arizona_annual_graduates":100,"arizona_projected_annual_openings":100,"active_postings":50, "graduate_academic_year":"latest","projection_period":"2022-2032","postings_observed_at":"2026-12-05T12:00:00Z", "geography":"Arizona","soc_to_cip_mapping_coverage":0.9, "graduate_source_url":"https://example.test/graduates","projection_source_url":"https://example.test/projections","posting_source_url":"https://example.test/jobs" diff --git a/cmd/nextpath/internal/web/templates.go b/cmd/nextpath/internal/web/templates.go index dfabc2a..d5b6f7c 100644 --- a/cmd/nextpath/internal/web/templates.go +++ b/cmd/nextpath/internal/web/templates.go @@ -24,4 +24,4 @@ const loginPage = `{{define "content"}}

Continue exploring.

What sounds interesting, {{.Name}}?

Rate the activity itself—not whether you are already good at it.

{{.Answered}} of {{.Total}} answered

{{.Question.Prompt}}

{{range $value := seq}}{{end}}
Not interestedUnsureVery interested
{{end}}` -const resultsPage = `{{define "content"}}

Your current interest profile

Hello {{.Name}}. Your three-letter exploration code is {{.Result.Code}}.

{{range .Result.Scores}}
{{.Dimension}}
{{.Percent}}%
{{end}}

Careers to explore next

Interest fit and Arizona market outlook are separate signals. The market percentage is a rough demand-to-completions comparison, not your probability of being hired.

{{range .Matches}}
O*NET-SOC {{.Occupation.ONETSOC}} · interest fit {{.FitScore}}%

{{.Occupation.Title}}

{{.Occupation.Summary}}

{{.Reason}}

{{if .Outlook}}
Arizona employability outlook: {{.Outlook.EmployabilityOutlookPercent}}%

{{.Outlook.Label}} · {{.Outlook.Confidence}} evidence confidence

{{.Outlook.Evidence.ArizonaProjectedOpenings}} projected openings/year and {{.Outlook.Evidence.ActiveEntryLevelPostings}} postings observed, compared with {{.Outlook.Evidence.ArizonaAnnualGraduates}} recent Arizona completions. Demand-to-completions ratio: {{.Outlook.AnnualDemandToGraduateRatio}}.

Formula: 75% projected annual demand coverage + 25% current posting coverage. Posting snapshot {{.Outlook.Evidence.PostingsObservedAt.Format "Jan 2, 2006"}}.

{{else}}

Arizona employability outlook unavailable. Complete source evidence has not been refreshed for this occupation; no percentage is estimated.

{{end}}

Try it first: {{.Occupation.TryFirst}}

Review the O*NET occupation profile
{{end}}

How to use this

{{.Result.InstrumentNotice}}

Confidence: {{.Result.Confidence}}. This describes interests, not ability or identity. Market outlook is contextual evidence, not a hiring promise.

Export my data

Delete account

{{end}}` +const resultsPage = `{{define "content"}}

Your current interest profile

Hello {{.Name}}. Your three-letter exploration code is {{.Result.Code}}.

{{range .Result.Scores}}
{{.Dimension}}
{{.Percent}}%
{{end}}

Careers to explore next

Interest fit and Arizona market outlook are separate signals. The market percentage is a rough demand-to-completions comparison, not your probability of being hired.

{{range .Matches}}
O*NET-SOC {{.Occupation.ONETSOC}} · interest fit {{.FitScore}}%

{{.Occupation.Title}}

{{.Occupation.Summary}}

{{.Reason}}

{{if .Outlook}}
Arizona employability outlook: {{.Outlook.EmployabilityOutlookPercent}}%

{{.Outlook.Label}} · {{.Outlook.Confidence}} evidence confidence

{{.Outlook.Evidence.ArizonaProjectedOpenings}} projected openings/year and {{.Outlook.Evidence.ActivePostings}} current postings observed, compared with {{.Outlook.Evidence.ArizonaAnnualGraduates}} recent Arizona completions. Demand-to-completions ratio: {{.Outlook.AnnualDemandToGraduateRatio}}.

Formula: 75% projected annual demand coverage + 25% current posting coverage. Postings include varying experience levels. Snapshot {{.Outlook.Evidence.PostingsObservedAt.Format "Jan 2, 2006"}}.

{{else}}

Arizona employability outlook unavailable. Complete source evidence has not been refreshed for this occupation; no percentage is estimated.

{{end}}

Try it first: {{.Occupation.TryFirst}}

Review the O*NET occupation profile
{{end}}

How to use this

{{.Result.InstrumentNotice}}

Confidence: {{.Result.Confidence}}. This describes interests, not ability or identity. Market outlook is contextual evidence, not a hiring promise.

Export my data

Delete account

{{end}}` diff --git a/docs/nextpath-architecture.md b/docs/nextpath-architecture.md index 807a380..5455e3d 100644 --- a/docs/nextpath-architecture.md +++ b/docs/nextpath-architecture.md @@ -61,7 +61,7 @@ authorization, or employer decisions. | Component | Weight | Evidence | | --- | ---: | --- | | 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 | +| Live posting coverage | 25 | Current occupation postings divided by annual Arizona completers | 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 @@ -91,6 +91,14 @@ Remote source data is cached with retrieval timestamps and source attribution. Job listings are short-lived examples, are linked to their publisher, and do not become training data or evidence of guaranteed employment. +Jeannie refreshes the cache daily from the public College Scorecard API and +CareerOneStop. The latter requires a private API user ID and bearer token. +They are stored as mode `0600` files outside release directories and are never +sent to the browser. A refresh replaces the cache atomically only after every +catalog occupation has all three inputs; failures preserve the last successful +snapshot. With no complete snapshot, the results page says the outlook is +unavailable rather than presenting a synthetic percentage. + ## Recommendation boundary Deterministic code performs assessment scoring, eligibility filtering, diff --git a/lib/jeannie/pipeline.sh b/lib/jeannie/pipeline.sh index 572fd83..570a6f7 100644 --- a/lib/jeannie/pipeline.sh +++ b/lib/jeannie/pipeline.sh @@ -6023,6 +6023,10 @@ deploy_nextpath() { local legacy_account_store="${install_dir}/accounts.json" local backup_dir="${install_dir}/backups" local backup_timestamp="" + local opportunity_store="${install_dir}/data/opportunity.json" + local credential_dir="${install_dir}/credentials" + local career_user_file="${credential_dir}/careeronestop-user-id" + local career_token_file="${credential_dir}/careeronestop-token" local elapsed=0 require_debian_server "deploy-nextpath" @@ -6042,7 +6046,7 @@ deploy_nextpath() { true|false) ;; *) echo "LAB_NEXTPATH_SECURE_COOKIES must be true or false." >&2; return 1 ;; esac - for required in go curl systemctl; do + for required in go curl systemctl python3; do if ! command -v "${required}" >/dev/null 2>&1; then echo "NextPath deployment requires ${required} on Debian." >&2 return 1 @@ -6052,9 +6056,21 @@ deploy_nextpath() { release_id="$(git -C "${REPO_ROOT}" rev-parse --verify HEAD)" release_dir="${install_dir}/releases/${release_id}" sudo install -d -o "${service_user}" -g "${service_user}" -m 0750 \ - "${install_dir}" "${install_dir}/releases" "${install_dir}/data" "${backup_dir}" + "${install_dir}" "${install_dir}/releases" "${install_dir}/data" "${backup_dir}" "${credential_dir}" sudo chmod 0700 "${install_dir}/data" sudo chmod 0700 "${backup_dir}" + sudo chmod 0700 "${credential_dir}" + + if [[ -n "${LAB_NEXTPATH_CAREERONESTOP_USER_ID:-}" || -n "${LAB_NEXTPATH_CAREERONESTOP_API_TOKEN:-}" ]]; then + if [[ -z "${LAB_NEXTPATH_CAREERONESTOP_USER_ID:-}" || -z "${LAB_NEXTPATH_CAREERONESTOP_API_TOKEN:-}" ]]; then + echo "Both LAB_NEXTPATH_CAREERONESTOP_USER_ID and LAB_NEXTPATH_CAREERONESTOP_API_TOKEN are required." >&2 + return 1 + fi + printf '%s' "${LAB_NEXTPATH_CAREERONESTOP_USER_ID}" | sudo tee "${career_user_file}" >/dev/null + printf '%s' "${LAB_NEXTPATH_CAREERONESTOP_API_TOKEN}" | sudo tee "${career_token_file}" >/dev/null + sudo chown "${service_user}:${service_user}" "${career_user_file}" "${career_token_file}" + sudo chmod 0600 "${career_user_file}" "${career_token_file}" + fi # The initial manual-preview instructions used the install root. Migrate # that file once, without ever replacing a store already managed by the @@ -6078,13 +6094,50 @@ deploy_nextpath() { echo "Preserved a private pre-deploy NextPath account backup in ${backup_dir}." fi sudo -u "${service_user}" install -d -m 0750 "${release_dir}" + sudo -u "${service_user}" install -d -m 0750 "${release_dir}/scripts" "${release_dir}/data" ( cd "${REPO_ROOT}" GOTOOLCHAIN=local go test ./cmd/nextpath/... GOTOOLCHAIN=local go build -trimpath -o "${release_dir}/nextpath" ./cmd/nextpath ) + sudo install -o "${service_user}" -g "${service_user}" -m 0550 \ + "${REPO_ROOT}/scripts/nextpath-opportunity-refresh.py" "${release_dir}/scripts/nextpath-opportunity-refresh.py" + sudo install -o "${service_user}" -g "${service_user}" -m 0440 \ + "${REPO_ROOT}/apps/nextpath/data/soc-cip-map.json" "${release_dir}/data/soc-cip-map.json" sudo -u "${service_user}" ln -sfn "${release_dir}" "${install_dir}/current" + sudo tee /etc/systemd/system/nextpath-opportunity-refresh.service >/dev/null </dev/null </dev/null <&2 + else + echo "NextPath evidence refresh failed and no prior snapshot is available." >&2 + sudo journalctl -u nextpath-opportunity-refresh.service -n 50 --no-pager >&2 || true + return 1 + fi + fi + sudo systemctl enable --now nextpath-opportunity-refresh.timer + else + sudo systemctl disable --now nextpath-opportunity-refresh.timer >/dev/null 2>&1 || true + echo "NextPath labor refresh is waiting for private CareerOneStop credentials; existing evidence cache was preserved." + fi sudo systemctl enable nextpath.service sudo systemctl restart nextpath.service diff --git a/scripts/nextpath-opportunity-refresh.py b/scripts/nextpath-opportunity-refresh.py index 24309b1..0657d23 100644 --- a/scripts/nextpath-opportunity-refresh.py +++ b/scripts/nextpath-opportunity-refresh.py @@ -109,7 +109,7 @@ def refresh(mapping_path: Path, output_path: Path, user_id: str, token: str, api occupations[onet] = { "arizona_annual_graduates": graduates, "arizona_projected_annual_openings": openings, - "active_entry_level_postings": postings, + "active_postings": postings, "graduate_academic_year": "latest College Scorecard IPEDS awards cohort", "projection_period": period, "postings_observed_at": observed.isoformat().replace("+00:00", "Z"), @@ -144,8 +144,14 @@ def main() -> None: parser.add_argument("--output", type=Path, required=True) parser.add_argument("--user-id", default=os.environ.get("CAREERONESTOP_USER_ID", "")) parser.add_argument("--token", default=os.environ.get("CAREERONESTOP_API_TOKEN", "")) + parser.add_argument("--user-id-file", type=Path) + parser.add_argument("--token-file", type=Path) parser.add_argument("--data-gov-key", default=os.environ.get("DATA_GOV_API_KEY", "DEMO_KEY")) args = parser.parse_args() + if args.user_id_file: + args.user_id = args.user_id_file.read_text().strip() + if args.token_file: + args.token = args.token_file.read_text().strip() if not args.user_id or not args.token: parser.error("CareerOneStop user ID and API token are required") refresh(args.mapping, args.output, args.user_id, args.token, args.data_gov_key) diff --git a/tests/jeannie/test_nextpath_pipeline.py b/tests/jeannie/test_nextpath_pipeline.py index a2748aa..2494d04 100644 --- a/tests/jeannie/test_nextpath_pipeline.py +++ b/tests/jeannie/test_nextpath_pipeline.py @@ -15,6 +15,14 @@ class NextPathPipelineTests(unittest.TestCase): self.assertIn('require_debian_server "deploy-nextpath"', pipeline) self.assertIn("GOTOOLCHAIN=local go test ./cmd/nextpath/...", pipeline) self.assertIn("NEXTPATH_ACCOUNT_STORE=${account_store}", pipeline) + self.assertIn("NEXTPATH_OPPORTUNITY_STORE=${opportunity_store}", pipeline) + self.assertIn("nextpath-opportunity-refresh.timer", pipeline) + self.assertIn("LAB_NEXTPATH_CAREERONESTOP_API_TOKEN", pipeline) + self.assertIn("--token-file ${career_token_file}", pipeline) + self.assertLess( + pipeline.index("systemctl start nextpath-opportunity-refresh.service"), + pipeline.index("systemctl restart nextpath.service"), + ) self.assertIn("ReadWritePaths=${install_dir}/data", pipeline) self.assertIn("sudo chmod 0700", pipeline) self.assertIn('legacy_account_store="${install_dir}/accounts.json"', pipeline)