Spaces:
Sleeping
Sleeping
| """Excel import constants β generated from SHACL shapes. | |
| DO NOT EDIT the SHACL-derived section below. Regenerate with: | |
| uofa schema --emit python -o src/uofa_cli/excel_constants.py | |
| Source shapes: | |
| /Users/vishnu/Library/CloudStorage/Dropbox/SystemsEngineering/Praxis/uofa_github/.claude/worktrees/musing-nash/packs/core/shapes/uofa_shacl.ttl | |
| /Users/vishnu/Library/CloudStorage/Dropbox/SystemsEngineering/Praxis/uofa_github/.claude/worktrees/musing-nash/packs/vv40/shapes/vv40_shapes.ttl | |
| /Users/vishnu/Library/CloudStorage/Dropbox/SystemsEngineering/Praxis/uofa_github/.claude/worktrees/musing-nash/packs/nasa-7009b/shapes/nasa_7009b_shapes.ttl | |
| """ | |
| from __future__ import annotations | |
| # ββ SHACL-derived constants (do not edit) βββββββββββββββββββββ | |
| VV40_FACTOR_NAMES: list[str] = [ | |
| "Software quality assurance", | |
| "Numerical code verification", | |
| "Discretization error", | |
| "Numerical solver error", | |
| "Use error", | |
| "Model form", | |
| "Model inputs", | |
| "Test samples", | |
| "Test conditions", | |
| "Equivalency of input parameters", | |
| "Output comparison", | |
| "Relevance of the quantities of interest", | |
| "Relevance of the validation activities to the COU", | |
| ] | |
| NASA_ALL_FACTOR_NAMES: list[str] = [ | |
| "Software quality assurance", | |
| "Numerical code verification", | |
| "Discretization error", | |
| "Numerical solver error", | |
| "Use error", | |
| "Model form", | |
| "Model inputs", | |
| "Test samples", | |
| "Test conditions", | |
| "Equivalency of input parameters", | |
| "Output comparison", | |
| "Relevance of the quantities of interest", | |
| "Relevance of the validation activities to the COU", | |
| "Data pedigree", | |
| "Development technical review", | |
| "Development process and product management", | |
| "Results uncertainty", | |
| "Results robustness", | |
| "Use history", | |
| ] | |
| NASA_ONLY_FACTOR_NAMES: list[str] = [ | |
| "Data pedigree", | |
| "Development technical review", | |
| "Development process and product management", | |
| "Results uncertainty", | |
| "Results robustness", | |
| "Use history", | |
| ] | |
| VV40_LEVEL_RANGE: tuple[int, int] = (1, 5) | |
| NASA_LEVEL_RANGE: tuple[int, int] = (0, 4) | |
| CORE_LEVEL_RANGE: tuple[int, int] = (0, 5) | |
| MRL_RANGE: tuple[int, int] = (1, 5) | |
| VALID_FACTOR_STATUSES: list[str] = [ | |
| "assessed", | |
| "not-assessed", | |
| "scoped-out", | |
| "not-applicable", | |
| ] | |
| VALID_ASSESSMENT_PHASES: list[str] = [ | |
| "capability", | |
| "results", | |
| ] | |
| VALID_DECISION_OUTCOMES: list[str] = [ | |
| "Accepted", | |
| "Not accepted", | |
| ] | |
| VALID_DEVICE_CLASSES: list[str] = [ | |
| "Class I", | |
| "Class II", | |
| "Class III", | |
| ] | |
| VALID_ASSURANCE_LEVELS: list[str] = [ | |
| "Low", | |
| "Medium", | |
| "High", | |
| ] | |
| VALID_PROFILES: list[str] = [ | |
| "Minimal", | |
| "Complete", | |
| ] | |
| EVIDENCE_TYPES: list[str] = [ | |
| "ValidationResult", | |
| "ReviewActivity", | |
| "ProcessAttestation", | |
| "DeploymentRecord", | |
| "InputPedigreeLink", | |
| ] | |
| # ββ Excel-specific constants (hand-maintained) ββββββββββββββββ | |
| SHEET_NAMES: dict[str, str] = { | |
| "summary": "Assessment Summary", | |
| "model_data": "Model & Data", | |
| "validation": "Validation Results", | |
| "factors": "Credibility Factors", | |
| "decision": "Decision", | |
| } | |
| # Row/column layout for each sheet | |
| HEADER_ROW = 3 # Row with column headers (rows 1-2 are title + instructions) | |
| DATA_START_ROW = 4 # First data row for Model & Data, Validation Results | |
| FACTOR_START_ROW = 5 # First factor data row in Credibility Factors | |
| # Factor type -> display category (for Excel template grouping) | |
| VV40_FACTOR_CATEGORIES: list[tuple[str, str]] = [ | |
| ("Software quality assurance", "Verification β Code"), | |
| ("Numerical code verification", "Verification β Code"), | |
| ("Discretization error", "Verification β Calculation"), | |
| ("Numerical solver error", "Verification β Calculation"), | |
| ("Use error", "Verification β Calculation"), | |
| ("Model form", "Validation β Model"), | |
| ("Model inputs", "Validation β Model"), | |
| ("Test samples", "Validation β Comparator"), | |
| ("Test conditions", "Validation β Comparator"), | |
| ("Equivalency of input parameters", "Validation β Assessment"), | |
| ("Output comparison", "Validation β Assessment"), | |
| ("Relevance of the quantities of interest", "Applicability"), | |
| ("Relevance of the validation activities to the COU", "Applicability"), | |
| ] | |
| NASA_ONLY_FACTOR_CATEGORIES: list[tuple[str, str]] = [ | |
| ("Data pedigree", "NASA β Capability"), | |
| ("Development technical review", "NASA β Capability"), | |
| ("Development process and product management", "NASA β Capability"), | |
| ("Results uncertainty", "NASA β Results"), | |
| ("Results robustness", "NASA β Results"), | |
| ("Use history", "NASA β Capability"), | |
| ] | |
| # ββ MRM-NIST (hand-maintained; mirrors packs/mrm-nist/shapes/mrm_nist_shapes.ttl) ββ | |
| # NIST AI RMF documentation factor set for the model-card unit. Presence-only | |
| # (status assessed / not-assessed / scoped-out); no 1-5 levels and no risk tiers, | |
| # per the pack spec. Grouped by the four RMF functions. NOT emitted by | |
| # `uofa schema --emit python` (which only knows core/vv40/nasa), so keep this in | |
| # sync with the pack shapes file by hand. | |
| MRM_NIST_FACTOR_NAMES: list[str] = [ | |
| # GOVERN β Governance & accountability | |
| "Ownership and accountability", | |
| "Intended use", | |
| "License and usage terms", | |
| "Out-of-scope use", | |
| # MAP β Context & risk framing | |
| "Task and domain context", | |
| "Deployment setting", | |
| "Known limitations", | |
| "Affected populations", | |
| # MEASURE β Evaluation & analysis | |
| "Evaluation metrics", | |
| "Evaluation methodology", | |
| "Bias and fairness analysis", | |
| "Robustness and safety testing", | |
| "Test and evaluation data", | |
| # MANAGE β Risk response & monitoring | |
| "Mitigations and safeguards", | |
| "Residual risk", | |
| "Monitoring and feedback", | |
| "Versioning and update policy", | |
| ] | |
| MRM_NIST_FACTOR_CATEGORIES: list[tuple[str, str]] = [ | |
| ("Ownership and accountability", "GOVERN β Governance & accountability"), | |
| ("Intended use", "GOVERN β Governance & accountability"), | |
| ("License and usage terms", "GOVERN β Governance & accountability"), | |
| ("Out-of-scope use", "GOVERN β Governance & accountability"), | |
| ("Task and domain context", "MAP β Context & risk framing"), | |
| ("Deployment setting", "MAP β Context & risk framing"), | |
| ("Known limitations", "MAP β Context & risk framing"), | |
| ("Affected populations", "MAP β Context & risk framing"), | |
| ("Evaluation metrics", "MEASURE β Evaluation & analysis"), | |
| ("Evaluation methodology", "MEASURE β Evaluation & analysis"), | |
| ("Bias and fairness analysis", "MEASURE β Evaluation & analysis"), | |
| ("Robustness and safety testing", "MEASURE β Evaluation & analysis"), | |
| ("Test and evaluation data", "MEASURE β Evaluation & analysis"), | |
| ("Mitigations and safeguards", "MANAGE β Risk response & monitoring"), | |
| ("Residual risk", "MANAGE β Risk response & monitoring"), | |
| ("Monitoring and feedback", "MANAGE β Risk response & monitoring"), | |
| ("Versioning and update policy", "MANAGE β Risk response & monitoring"), | |
| ] | |
| # GOVERN/MANAGE subcategories that a static model card rarely documents as an | |
| # organizational act. Marked scoped-out (out-of-scope-at-card-level) by default | |
| # rather than not-assessed, so a genuine documentation omission is not conflated | |
| # with an organizational artifact the card was never meant to carry. The S0 | |
| # curate step flips one to assessed when a card actually documents it (e.g. OLMo | |
| # states a versioning/update policy). This is the v0.8 Β§8 open question resolved | |
| # the honest way for the demo. | |
| MRM_NIST_DEFAULT_OUT_OF_SCOPE: frozenset[str] = frozenset({ | |
| "Ownership and accountability", | |
| "Mitigations and safeguards", | |
| "Residual risk", | |
| "Monitoring and feedback", | |
| "Versioning and update policy", | |
| }) | |
| ALL_FACTOR_CATEGORIES: list[tuple[str, str]] = ( | |
| VV40_FACTOR_CATEGORIES + NASA_ONLY_FACTOR_CATEGORIES + MRM_NIST_FACTOR_CATEGORIES | |
| ) | |
| # NASA category -> assessmentPhase mapping | |
| NASA_PHASE_MAP: dict[str, str] = { | |
| "NASA \u2014 Capability": "capability", | |
| "NASA \u2014 Results": "results", | |
| } | |
| # Profile name -> JSON-LD URI | |
| PROFILE_URIS: dict[str, str] = { | |
| "Minimal": "https://uofa.net/vocab#ProfileMinimal", | |
| "Complete": "https://uofa.net/vocab#ProfileComplete", | |
| } | |
| # Factor standard assignment | |
| FACTOR_STANDARD_VV40 = "ASME-VV40-2018" | |
| FACTOR_STANDARD_NASA = "NASA-STD-7009B" | |
| FACTOR_STANDARD_MRM_NIST = "NIST-AI-RMF-1.0" | |
| CONTEXT_URL = "https://raw.githubusercontent.com/cloudronin/uofa/main/spec/context/v0.5.jsonld" | |
| BASE_URI = "https://uofa.net/instances" | |
| # ββ Hand-maintained normalizers βββββββββββββββββββββββββββββββ | |
| def normalize_evidence_type(value: str) -> tuple[str, bool]: | |
| """Map an evidence_type cell value to the canonical EVIDENCE_TYPES enum. | |
| Returns ``(normalized_value, was_substituted)``. LLM extractors sometimes | |
| emit descriptive domain labels (e.g. ``GridConvergenceStudy``, | |
| ``CodeVerification``) instead of the constrained core enum. This | |
| normalizer: | |
| 1. Returns the value unchanged if already canonical. | |
| 2. Tries a difflib fuzzy match (cutoff=0.6) β handles typos and minor | |
| variants like ``ValidationResults`` vs ``ValidationResult``. | |
| 3. Falls back to ``ValidationResult`` (the most common case, and the | |
| reader's default for empty cells). | |
| """ | |
| import difflib | |
| if value in EVIDENCE_TYPES: | |
| return value, False | |
| matches = difflib.get_close_matches(value, EVIDENCE_TYPES, n=1, cutoff=0.6) | |
| if matches: | |
| return matches[0], True | |
| return "ValidationResult", True | |