aibvf 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aibvf-0.1.0/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ node_modules/
2
+ dist/
3
+ *.tsbuildinfo
4
+ __pycache__/
5
+ *.pyc
6
+ .venv/
7
+ venv/
8
+ .DS_Store
9
+ build/
10
+ *.egg-info/
11
+ .pytest_cache/
12
+ .mypy_cache/
13
+ .ruff_cache/
aibvf-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,78 @@
1
+ Metadata-Version: 2.4
2
+ Name: aibvf
3
+ Version: 0.1.0
4
+ Summary: AI BVF — open protocol for scoring AI investments. Validator and scoring engine.
5
+ Project-URL: Homepage, https://bvf-app.vercel.app/protocol
6
+ Project-URL: Repository, https://github.com/craighorton/ai-bvf
7
+ Author: Craig Horton
8
+ License: MIT
9
+ Keywords: ai,ai-governance,ai-roi,ai-scoring,bvf,enterprise-ai,eu-ai-act,standards
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Requires-Python: >=3.9
21
+ Provides-Extra: jsonschema
22
+ Requires-Dist: jsonschema>=4.0; extra == 'jsonschema'
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest>=7.0; extra == 'test'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # aibvf
28
+
29
+ AI BVF v1.0 — open protocol for scoring AI investments. Python implementation.
30
+
31
+ ```bash
32
+ pip install aibvf
33
+ ```
34
+
35
+ ## Validate a portfolio
36
+
37
+ ```python
38
+ from aibvf import validate
39
+ import json
40
+
41
+ portfolio = json.load(open('my-portfolio.json'))
42
+ result = validate(portfolio)
43
+ if not result['valid']:
44
+ for err in result['errors']:
45
+ print(f"{err['path']}: {err['msg']}")
46
+ ```
47
+
48
+ ## Score an initiative
49
+
50
+ ```python
51
+ from aibvf import score
52
+
53
+ r = score(
54
+ industry='manufacturing',
55
+ revenue_eur=2_400_000_000,
56
+ function='supply',
57
+ ai_tier='gen2',
58
+ readiness='traditional',
59
+ scores={
60
+ 'strategic_alignment': 72,
61
+ 'financial_return': 64,
62
+ 'change_enablement': 48,
63
+ 'governance_risk': 35,
64
+ },
65
+ )
66
+
67
+ print(r['classification']) # 'Fix'
68
+ print(r['net_low_eur']) # ~75.6M
69
+ print(r['net_high_eur']) # ~247M
70
+ ```
71
+
72
+ ## Spec
73
+
74
+ Full specification at <https://bvf-app.vercel.app/protocol>.
75
+
76
+ ## License
77
+
78
+ MIT. Underlying specification is CC-BY-4.0.
aibvf-0.1.0/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # aibvf
2
+
3
+ AI BVF v1.0 — open protocol for scoring AI investments. Python implementation.
4
+
5
+ ```bash
6
+ pip install aibvf
7
+ ```
8
+
9
+ ## Validate a portfolio
10
+
11
+ ```python
12
+ from aibvf import validate
13
+ import json
14
+
15
+ portfolio = json.load(open('my-portfolio.json'))
16
+ result = validate(portfolio)
17
+ if not result['valid']:
18
+ for err in result['errors']:
19
+ print(f"{err['path']}: {err['msg']}")
20
+ ```
21
+
22
+ ## Score an initiative
23
+
24
+ ```python
25
+ from aibvf import score
26
+
27
+ r = score(
28
+ industry='manufacturing',
29
+ revenue_eur=2_400_000_000,
30
+ function='supply',
31
+ ai_tier='gen2',
32
+ readiness='traditional',
33
+ scores={
34
+ 'strategic_alignment': 72,
35
+ 'financial_return': 64,
36
+ 'change_enablement': 48,
37
+ 'governance_risk': 35,
38
+ },
39
+ )
40
+
41
+ print(r['classification']) # 'Fix'
42
+ print(r['net_low_eur']) # ~75.6M
43
+ print(r['net_high_eur']) # ~247M
44
+ ```
45
+
46
+ ## Spec
47
+
48
+ Full specification at <https://bvf-app.vercel.app/protocol>.
49
+
50
+ ## License
51
+
52
+ MIT. Underlying specification is CC-BY-4.0.
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "aibvf"
7
+ version = "0.1.0"
8
+ description = "AI BVF — open protocol for scoring AI investments. Validator and scoring engine."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Craig Horton" }]
12
+ requires-python = ">=3.9"
13
+ keywords = ["ai", "bvf", "ai-governance", "enterprise-ai", "ai-scoring", "ai-roi", "eu-ai-act", "standards"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Financial and Insurance Industry",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Topic :: Software Development :: Libraries",
25
+ ]
26
+ dependencies = []
27
+
28
+ [project.optional-dependencies]
29
+ jsonschema = ["jsonschema>=4.0"]
30
+ test = ["pytest>=7.0"]
31
+
32
+ [project.urls]
33
+ Homepage = "https://bvf-app.vercel.app/protocol"
34
+ Repository = "https://github.com/craighorton/ai-bvf"
35
+
36
+ [tool.hatch.build]
37
+ include = ["src/aibvf/**", "src/aibvf/schema/*.json"]
38
+
39
+ [tool.hatch.build.targets.wheel]
40
+ packages = ["src/aibvf"]
@@ -0,0 +1,23 @@
1
+ """AI BVF v1.0 — open protocol for scoring AI investments."""
2
+
3
+ from .validate import validate
4
+ from .score import score, BASE_RATES, IND_MULT, TIER_ADJ, READINESS_CAPTURE
5
+ from .taxonomy import INDUSTRIES, FUNCTIONS, AI_TIERS, READINESS
6
+ from .schema import load_schema
7
+
8
+ BVF_VERSION = "1.0"
9
+
10
+ __all__ = [
11
+ "validate",
12
+ "score",
13
+ "BASE_RATES",
14
+ "IND_MULT",
15
+ "TIER_ADJ",
16
+ "READINESS_CAPTURE",
17
+ "INDUSTRIES",
18
+ "FUNCTIONS",
19
+ "AI_TIERS",
20
+ "READINESS",
21
+ "load_schema",
22
+ "BVF_VERSION",
23
+ ]
File without changes
@@ -0,0 +1,23 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bvf-app.vercel.app/bvf-protocol.schema.json",
4
+ "title": "AI BVF Portfolio v1.0",
5
+ "type": "object",
6
+ "required": ["bvf_version", "organization", "initiatives"],
7
+ "properties": {
8
+ "bvf_version": { "type": "string", "const": "1.0" },
9
+ "generated_at": { "type": "string", "format": "date-time" },
10
+ "organization": {
11
+ "type": "object",
12
+ "required": ["name", "industry"],
13
+ "properties": {
14
+ "name": { "type": "string" },
15
+ "industry": { "type": "string", "enum": ["universal","creative","education","energy","financial","healthcare","logistics","manufacturing","nonprofit","professional","public_sector","real_estate","retail","technology"] },
16
+ "region": { "type": "string" },
17
+ "revenue_eur": { "type": "number", "minimum": 0 },
18
+ "headcount": { "type": "integer", "minimum": 0 }
19
+ }
20
+ },
21
+ "initiatives": { "type": "array", "minItems": 1 }
22
+ }
23
+ }
@@ -0,0 +1,9 @@
1
+ """Loads the canonical AI BVF v1.0 JSON Schema bundled with the package."""
2
+ import json
3
+ from importlib import resources
4
+
5
+
6
+ def load_schema() -> dict:
7
+ """Returns the AI BVF v1.0 JSON Schema as a dict."""
8
+ with resources.files("aibvf.schema").joinpath("bvf-protocol.schema.json").open("r", encoding="utf-8") as fh:
9
+ return json.load(fh)
@@ -0,0 +1,91 @@
1
+ """AI BVF v1.0 scoring engine. Deterministic, no dependencies."""
2
+ from __future__ import annotations
3
+
4
+ BASE_RATES = {
5
+ "finance": {"rev": {"lo": 0.010, "hi": 0.030}, "cost": {"lo": 0.030, "hi": 0.060}, "drivers": ["Automated financial close (-40% cycle time)", "AI FP&A & forecasting", "Anomaly detection reducing write-offs"], "source": "McKinsey Global Institute — Finance AI benchmark"},
6
+ "hr": {"rev": {"lo": 0.005, "hi": 0.015}, "cost": {"lo": 0.020, "hi": 0.040}, "drivers": ["Attrition reduction (-15-25% replacement cost)", "GenAI HR service desk (-30% AHT)", "Skills-based talent deployment"], "source": "Deloitte Future of Work 2024"},
7
+ "sales": {"rev": {"lo": 0.030, "hi": 0.080}, "cost": {"lo": 0.010, "hi": 0.025}, "drivers": ["Hyper-personalisation at scale", "Predictive lead scoring & pipeline accuracy", "AI deal coaching"], "source": "McKinsey — AI personalisation drives up to 40% revenue uplift"},
8
+ "supply": {"rev": {"lo": 0.005, "hi": 0.015}, "cost": {"lo": 0.040, "hi": 0.090}, "drivers": ["Predictive maintenance (-10-25% unplanned downtime)", "Inventory optimisation (-15% holding cost)", "Quality defect AI (-20% rework)"], "source": "Gartner Supply Chain AI Benchmark 2024"},
9
+ "cx": {"rev": {"lo": 0.020, "hi": 0.050}, "cost": {"lo": 0.020, "hi": 0.050}, "drivers": ["GenAI deflection (up to 87% self-service)", "AHT reduction -20-35%", "Retention uplift from personalisation"], "source": "Forrester CX AI Impact 2024"},
10
+ "risk": {"rev": {"lo": 0.005, "hi": 0.010}, "cost": {"lo": 0.020, "hi": 0.040}, "drivers": ["AML false-positive reduction -30-50%", "Automated CSRD / EU AI Act reporting", "Continuous compliance monitoring"], "source": "Accenture Regulatory AI Report 2024"},
11
+ "it": {"rev": {"lo": 0.005, "hi": 0.015}, "cost": {"lo": 0.030, "hi": 0.070}, "drivers": ["MTTR reduction -20-40%", "AIOps incident prevention", "GenAI ITSM auto-resolution"], "source": "ServiceNow Platform Value Report 2024"},
12
+ "rd": {"rev": {"lo": 0.010, "hi": 0.040}, "cost": {"lo": 0.010, "hi": 0.030}, "drivers": ["Compressed time-to-market (-20-35% dev cycle)", "AI-assisted design & simulation", "IP analysis"], "source": "BCG — AI in R&D: The Next Frontier 2024"},
13
+ }
14
+
15
+ IND_MULT = {
16
+ "universal": {"finance": 1.0, "hr": 1.0, "sales": 1.0, "supply": 1.0, "cx": 1.0, "risk": 1.0, "it": 1.0, "rd": 1.0},
17
+ "creative": {"finance": 1.0, "hr": 1.0, "sales": 1.3, "supply": 1.0, "cx": 1.3, "risk": 1.0, "it": 1.0, "rd": 1.2},
18
+ "education": {"finance": 1.0, "hr": 1.2, "sales": 1.0, "supply": 1.0, "cx": 1.0, "risk": 1.0, "it": 1.2, "rd": 1.4},
19
+ "energy": {"finance": 1.0, "hr": 1.0, "sales": 1.0, "supply": 1.4, "cx": 1.0, "risk": 1.3, "it": 1.3, "rd": 1.0},
20
+ "financial": {"finance": 1.4, "hr": 1.1, "sales": 1.2, "supply": 0.7, "cx": 1.3, "risk": 1.5, "it": 1.1, "rd": 0.8},
21
+ "healthcare": {"finance": 1.1, "hr": 1.1, "sales": 1.0, "supply": 0.8, "cx": 1.1, "risk": 1.4, "it": 1.0, "rd": 1.5},
22
+ "logistics": {"finance": 1.2, "hr": 1.0, "sales": 1.0, "supply": 1.5, "cx": 1.0, "risk": 1.0, "it": 1.3, "rd": 1.0},
23
+ "manufacturing": {"finance": 1.0, "hr": 1.0, "sales": 0.9, "supply": 1.4, "cx": 0.9, "risk": 1.1, "it": 1.3, "rd": 1.1},
24
+ "nonprofit": {"finance": 1.1, "hr": 1.2, "sales": 1.0, "supply": 1.0, "cx": 1.2, "risk": 1.0, "it": 1.0, "rd": 1.0},
25
+ "professional": {"finance": 1.0, "hr": 1.2, "sales": 1.4, "supply": 1.0, "cx": 1.3, "risk": 1.0, "it": 1.0, "rd": 1.0},
26
+ "public_sector": {"finance": 1.0, "hr": 1.2, "sales": 1.0, "supply": 1.0, "cx": 1.0, "risk": 1.3, "it": 1.2, "rd": 1.0},
27
+ "real_estate": {"finance": 1.3, "hr": 1.0, "sales": 1.2, "supply": 1.2, "cx": 1.0, "risk": 1.0, "it": 1.0, "rd": 1.0},
28
+ "retail": {"finance": 1.0, "hr": 1.0, "sales": 1.4, "supply": 1.2, "cx": 1.4, "risk": 0.9, "it": 1.0, "rd": 0.8},
29
+ "technology": {"finance": 1.0, "hr": 1.1, "sales": 1.2, "supply": 0.8, "cx": 1.1, "risk": 1.0, "it": 1.4, "rd": 1.4},
30
+ }
31
+
32
+ TIER_ADJ = {"gen1": 0.55, "gen2": 1.00, "gen3": 1.35}
33
+
34
+ READINESS_CAPTURE = {
35
+ "agile": {"low": 0.85, "high": 1.00, "label": "Agile & Collaborative"},
36
+ "traditional": {"low": 0.50, "high": 0.70, "label": "Traditional Hierarchy"},
37
+ "siloed": {"low": 0.25, "high": 0.40, "label": "Siloed & Bureaucratic"},
38
+ }
39
+
40
+
41
+ def _classify(sa: float, fr: float, ce: float, gr: float) -> dict:
42
+ if gr >= 70 or fr <= 20:
43
+ return {"label": "Stop", "reason": "Governance risk above the safe threshold." if gr >= 70 else "Financial return too thin to justify scope."}
44
+ if sa >= 60 and fr >= 60 and ce >= 60 and gr <= 40:
45
+ return {"label": "Accelerate", "reason": "All four pillars clear, governance contained. Fund it."}
46
+ gaps = []
47
+ if sa < 60: gaps.append("strategic alignment is weak")
48
+ if fr < 60: gaps.append("financial return is thin")
49
+ if ce < 60: gaps.append("change enablement is a risk")
50
+ if gr > 40: gaps.append("governance exposure is real")
51
+ return {"label": "Fix", "reason": f"Workable, but {'; '.join(gaps)}. Close the gap before scaling."}
52
+
53
+
54
+ def score(*, industry: str, revenue_eur: float, function: str, ai_tier: str, readiness: str, scores: dict) -> dict:
55
+ """Score an initiative according to AI BVF v1.0. Deterministic."""
56
+ base = BASE_RATES.get(function)
57
+ if base is None:
58
+ raise ValueError(f"Unknown function: {function}")
59
+ mult = IND_MULT.get(industry, IND_MULT["universal"]).get(function, 1.0)
60
+ t_adj = TIER_ADJ.get(ai_tier)
61
+ if t_adj is None:
62
+ raise ValueError(f"Unknown ai_tier: {ai_tier}")
63
+ cap = READINESS_CAPTURE.get(readiness)
64
+ if cap is None:
65
+ raise ValueError(f"Unknown readiness: {readiness}")
66
+
67
+ sa = scores["strategic_alignment"]
68
+ fr = scores["financial_return"]
69
+ ce = scores["change_enablement"]
70
+ gr = scores["governance_risk"]
71
+
72
+ gross_lo = revenue_eur * (base["rev"]["lo"] + base["cost"]["lo"]) * mult * t_adj
73
+ gross_hi = revenue_eur * (base["rev"]["hi"] + base["cost"]["hi"]) * mult * t_adj
74
+ net_lo = gross_lo * cap["low"]
75
+ net_hi = gross_hi * cap["high"]
76
+
77
+ cls = _classify(sa, fr, ce, gr)
78
+ confidence = round((sa + fr + ce + (100 - gr)) / 4)
79
+
80
+ return {
81
+ "classification": cls["label"],
82
+ "reason": cls["reason"],
83
+ "gross_low_eur": gross_lo,
84
+ "gross_high_eur": gross_hi,
85
+ "net_low_eur": net_lo,
86
+ "net_high_eur": net_hi,
87
+ "confidence": confidence,
88
+ "multipliers": {"industry": mult, "tier": t_adj, "capture_low": cap["low"], "capture_high": cap["high"]},
89
+ "drivers": base["drivers"],
90
+ "source": base["source"],
91
+ }
@@ -0,0 +1,43 @@
1
+ INDUSTRIES = [
2
+ "universal", "creative", "education", "energy", "financial", "healthcare",
3
+ "logistics", "manufacturing", "nonprofit", "professional", "public_sector",
4
+ "real_estate", "retail", "technology",
5
+ ]
6
+
7
+ FUNCTIONS = ["finance", "hr", "sales", "supply", "cx", "risk", "it", "rd"]
8
+ AI_TIERS = ["gen1", "gen2", "gen3"]
9
+ READINESS = ["agile", "traditional", "siloed"]
10
+
11
+ INDUSTRY_LABEL = {
12
+ "universal": "Universal / Other",
13
+ "creative": "Creative & Media",
14
+ "education": "Education & Research",
15
+ "energy": "Energy & Utilities",
16
+ "financial": "Financial Services",
17
+ "healthcare": "Healthcare / MedTech",
18
+ "logistics": "Logistics & Transportation",
19
+ "manufacturing": "Manufacturing & Supply Chain",
20
+ "nonprofit": "Non-Profit & NGO",
21
+ "professional": "Professional Services",
22
+ "public_sector": "Public Sector & Government",
23
+ "real_estate": "Real Estate & Construction",
24
+ "retail": "Retail / Consumer",
25
+ "technology": "Technology",
26
+ }
27
+
28
+ FUNCTION_LABEL = {
29
+ "finance": "Finance & CFO",
30
+ "hr": "HR & Workforce",
31
+ "sales": "Sales & Revenue",
32
+ "supply": "Supply Chain",
33
+ "cx": "Customer Experience",
34
+ "risk": "Risk & Compliance",
35
+ "it": "IT & Platform",
36
+ "rd": "R&D / Innovation",
37
+ }
38
+
39
+ TIER_LABEL = {
40
+ "gen1": "Gen 1 — Automation (RPA)",
41
+ "gen2": "Gen 2 — GenAI",
42
+ "gen3": "Gen 3 — Agentic",
43
+ }
@@ -0,0 +1,97 @@
1
+ """Hand-rolled validator for AI BVF v1.0 portfolios. Zero dependencies."""
2
+ from __future__ import annotations
3
+ import re
4
+ from typing import Any
5
+
6
+ from .taxonomy import INDUSTRIES, FUNCTIONS, AI_TIERS
7
+
8
+ _PILLARS = ("strategic_alignment", "financial_return", "change_enablement", "governance_risk")
9
+ _BUCKETS = ("Agent-Proof", "Agent-Augmented", "Agent-Replaceable")
10
+ _CLASSIFICATIONS = ("Accelerate", "Fix", "Stop")
11
+ _COMPLIANCE = ("eu_ai_act", "dora", "csrd", "gdpr_ai")
12
+ _ID_RE = re.compile(r"^[a-z0-9-]{1,64}$")
13
+
14
+
15
+ def validate(doc: Any) -> dict:
16
+ """Validate a portfolio document against AI BVF v1.0.
17
+
18
+ Returns { "valid": bool, "errors": [{"path": str, "msg": str}, ...] }.
19
+ """
20
+ errors: list[dict] = []
21
+
22
+ def push(path: str, msg: str) -> None:
23
+ errors.append({"path": path, "msg": msg})
24
+
25
+ if not isinstance(doc, dict):
26
+ return {"valid": False, "errors": [{"path": "", "msg": "Document must be a JSON object."}]}
27
+
28
+ if doc.get("bvf_version") != "1.0":
29
+ push("bvf_version", 'Required. Must be the string "1.0".')
30
+
31
+ org = doc.get("organization")
32
+ if not isinstance(org, dict):
33
+ push("organization", "Required object.")
34
+ else:
35
+ if not isinstance(org.get("name"), str) or not org["name"]:
36
+ push("organization.name", "Required string.")
37
+ if org.get("industry") not in INDUSTRIES:
38
+ push("organization.industry", f"Must be one of: {', '.join(INDUSTRIES)}.")
39
+ if "revenue_eur" in org and (not isinstance(org["revenue_eur"], (int, float)) or org["revenue_eur"] < 0):
40
+ push("organization.revenue_eur", "Must be a non-negative number.")
41
+
42
+ inits = doc.get("initiatives")
43
+ if not isinstance(inits, list) or not inits:
44
+ push("initiatives", "Required. Must be a non-empty array.")
45
+ else:
46
+ for i, init in enumerate(inits):
47
+ base = f"initiatives[{i}]"
48
+ if not isinstance(init, dict):
49
+ push(base, "Must be an object.")
50
+ continue
51
+ iid = init.get("id")
52
+ if not isinstance(iid, str) or not _ID_RE.match(iid):
53
+ push(f"{base}.id", "Required. Lowercase letters, digits, hyphens only (max 64).")
54
+ name = init.get("name")
55
+ if not isinstance(name, str) or not name:
56
+ push(f"{base}.name", "Required string.")
57
+ elif len(name) > 240:
58
+ push(f"{base}.name", "Exceeds 240 characters.")
59
+ if init.get("function") not in FUNCTIONS:
60
+ push(f"{base}.function", f"Must be one of: {', '.join(FUNCTIONS)}.")
61
+ if init.get("ai_tier") not in AI_TIERS:
62
+ push(f"{base}.ai_tier", f"Must be one of: {', '.join(AI_TIERS)}.")
63
+ if "bucket" in init and init["bucket"] not in _BUCKETS:
64
+ push(f"{base}.bucket", f"Must be one of: {', '.join(_BUCKETS)}.")
65
+
66
+ scores = init.get("scores")
67
+ if not isinstance(scores, dict):
68
+ push(f"{base}.scores", "Required object with all four pillar scores.")
69
+ else:
70
+ for p in _PILLARS:
71
+ ps = scores.get(p)
72
+ if not isinstance(ps, dict):
73
+ push(f"{base}.scores.{p}", "Required pillar score object.")
74
+ continue
75
+ v = ps.get("value")
76
+ if not isinstance(v, (int, float)) or v < 0 or v > 100:
77
+ push(f"{base}.scores.{p}.value", "Required. Number in [0, 100].")
78
+ if "confidence" in ps:
79
+ c = ps["confidence"]
80
+ if not isinstance(c, (int, float)) or c < 0 or c > 100:
81
+ push(f"{base}.scores.{p}.confidence", "Optional. Number in [0, 100].")
82
+
83
+ if "classification" in init and init["classification"] not in _CLASSIFICATIONS:
84
+ push(f"{base}.classification", f"Must be one of: {', '.join(_CLASSIFICATIONS)}.")
85
+ if "decision_confidence" in init:
86
+ v = init["decision_confidence"]
87
+ if not isinstance(v, (int, float)) or v < 0 or v > 100:
88
+ push(f"{base}.decision_confidence", "Must be a number in [0, 100].")
89
+ if "compliance" in init:
90
+ if not isinstance(init["compliance"], list):
91
+ push(f"{base}.compliance", "Must be an array.")
92
+ else:
93
+ for j, c in enumerate(init["compliance"]):
94
+ if c not in _COMPLIANCE:
95
+ push(f"{base}.compliance[{j}]", f"Must be one of: {', '.join(_COMPLIANCE)}.")
96
+
97
+ return {"valid": not errors, "errors": errors}