livingproof-capability-report 5.0.5__py3-none-any.whl

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.
Files changed (40) hide show
  1. livingproof_capability_report/__init__.py +16 -0
  2. livingproof_capability_report/__main__.py +3 -0
  3. livingproof_capability_report/_build_provenance.json +14 -0
  4. livingproof_capability_report/assessed.py +192 -0
  5. livingproof_capability_report/bundle.schema.json +226 -0
  6. livingproof_capability_report/cli.py +411 -0
  7. livingproof_capability_report/comment.py +73 -0
  8. livingproof_capability_report/core.py +596 -0
  9. livingproof_capability_report/evaluators.py +1804 -0
  10. livingproof_capability_report/fonts/DMSans-latin-ext.woff2 +0 -0
  11. livingproof_capability_report/fonts/DMSans-latin.woff2 +0 -0
  12. livingproof_capability_report/fonts/OFL.txt +93 -0
  13. livingproof_capability_report/html_theme.py +1669 -0
  14. livingproof_capability_report/legacy_evidence.py +145 -0
  15. livingproof_capability_report/links.py +418 -0
  16. livingproof_capability_report/narrative.py +342 -0
  17. livingproof_capability_report/pinned_inputs.py +49 -0
  18. livingproof_capability_report/presentation.py +85 -0
  19. livingproof_capability_report/provenance.py +37 -0
  20. livingproof_capability_report/sections.py +308 -0
  21. livingproof_capability_report/site/__init__.py +27 -0
  22. livingproof_capability_report/site/assemble.py +2011 -0
  23. livingproof_capability_report/site/assets/open.js +125 -0
  24. livingproof_capability_report/site/assets/styles.css +681 -0
  25. livingproof_capability_report/site/check.py +78 -0
  26. livingproof_capability_report/site/common.py +103 -0
  27. livingproof_capability_report/site/details.py +97 -0
  28. livingproof_capability_report/site/pages.py +1384 -0
  29. livingproof_capability_report/steps.py +859 -0
  30. livingproof_capability_report/svg_icon.py +122 -0
  31. livingproof_capability_report/trial_binding.py +17 -0
  32. livingproof_capability_report/trusted_viewer.py +222 -0
  33. livingproof_capability_report/version.py +17 -0
  34. livingproof_capability_report/viewer_page.py +187 -0
  35. livingproof_capability_report-5.0.5.dist-info/METADATA +669 -0
  36. livingproof_capability_report-5.0.5.dist-info/RECORD +40 -0
  37. livingproof_capability_report-5.0.5.dist-info/WHEEL +4 -0
  38. livingproof_capability_report-5.0.5.dist-info/entry_points.txt +5 -0
  39. livingproof_capability_report-5.0.5.dist-info/licenses/LICENSE +73 -0
  40. livingproof_capability_report-5.0.5.dist-info/licenses/NOTICE +6 -0
@@ -0,0 +1,16 @@
1
+ """Importable reporting operations; no command-line or producer dependency."""
2
+
3
+ from .assessed import report_from_bundle
4
+ from .presentation import EvaluatorPresentation
5
+ from .trusted_viewer import TrustedViewer
6
+ from .core import aggregate, load_bundle, render, validate_bundle
7
+
8
+ __all__ = [
9
+ "aggregate",
10
+ "load_bundle",
11
+ "render",
12
+ "report_from_bundle",
13
+ "validate_bundle",
14
+ "EvaluatorPresentation",
15
+ "TrustedViewer",
16
+ ]
@@ -0,0 +1,3 @@
1
+ from .cli import report
2
+
3
+ report(prog_name="livingproof-capability-report")
@@ -0,0 +1,14 @@
1
+ {
2
+ "distribution": "livingproof-capability-report",
3
+ "format_version": 1,
4
+ "identity": {
5
+ "base_version": "5.0.5",
6
+ "branch": "main-0d6e4079",
7
+ "commit": "c2d5e88d67c2f85ec08523beda81df17756250bc",
8
+ "distance": 0,
9
+ "format_version": 1,
10
+ "history": "tagged",
11
+ "state": "clean"
12
+ },
13
+ "package_version": "5.0.5"
14
+ }
@@ -0,0 +1,192 @@
1
+ """Bundle 1.1.0: render the capability verifier's decisions and run assessments as stored.
2
+
3
+ Nothing here grades. Per-result statuses come from each result's ``decision`` and per-run
4
+ k of N, interval and grade from the bundle's ``assessment`` (livingproof-run-assessment/0.1,
5
+ robot-capability-specs). When that assessment stored a ``reproducibility`` object it is
6
+ copied onto the summary; assessments that omit it keep today's summary shape. The report
7
+ keeps the report 1.0.0 document layout that reporter 1.x wrote, so ``render`` and
8
+ ``comment`` print the same bytes; ``wilson95`` is kept. Null ``k``, ``n`` and interval
9
+ bounds are not a success rate.
10
+
11
+ A missing or malformed field is an error naming the field and the result. The one check
12
+ made against the evidence is integrity: a stored PASS whose evidence is missing or changed
13
+ is refused rather than shown.
14
+ """
15
+
16
+ import copy
17
+
18
+ from . import core
19
+ from . import links as elinks
20
+
21
+ BUNDLE_VERSION = "1.1.0"
22
+ FORMAT = "livingproof-run-assessment/0.1"
23
+ STATUSES = {core.PASS, core.FAIL, core.INSUFFICIENT, core.INCOMPATIBLE}
24
+ SUMMARY_KEYS = (
25
+ "capability",
26
+ "spec",
27
+ "system",
28
+ "environment",
29
+ "run_id",
30
+ "k",
31
+ "n",
32
+ "required_passes",
33
+ "wilson95",
34
+ "grade",
35
+ "result_ids",
36
+ "failures",
37
+ "prototype",
38
+ )
39
+ RUN_KEYS = tuple(k for k in SUMMARY_KEYS if k != "wilson95") + ("interval",)
40
+ # A run nobody graded (no evaluator that grades was declared) leaves the grade fields
41
+ # out entirely, and its trials carry no decision (#252). The summary keeps only these.
42
+ UNGRADED_KEYS = ("capability", "spec", "system", "environment", "run_id", "result_ids")
43
+ GRADE_KEYS = ("k", "n", "required_passes", "interval", "grade", "rationale", "failures")
44
+
45
+
46
+ def is_assessed(bundle):
47
+ return isinstance(bundle, dict) and bundle.get("schema_version") == BUNDLE_VERSION
48
+
49
+
50
+ def _need(container, key, where, kind=None):
51
+ if not isinstance(container, dict) or key not in container:
52
+ raise ValueError(f"Bundle 1.1.0: {where} is missing required field '{key}'")
53
+ value = container[key]
54
+ if kind is not None and not isinstance(value, kind):
55
+ raise ValueError(f"Bundle 1.1.0: {where} field '{key}' must be {kind.__name__}")
56
+ return value
57
+
58
+
59
+ def _decision(result):
60
+ """The stored decision, or None when the trial carries none (#252)."""
61
+ if "decision" not in result:
62
+ return None
63
+ where = f"result '{result['id']}'"
64
+ stored = _need(result, "decision", where, dict)
65
+ where = f"result '{result['id']}' decision"
66
+ status = _need(stored, "status", where, str)
67
+ if status not in STATUSES:
68
+ raise ValueError(f"Bundle 1.1.0: {where} field 'status' is not a known status: {status!r}")
69
+ decision = {"result_id": result["id"], "status": status}
70
+ decision["reason"] = _need(stored, "reason", where, str)
71
+ _need(stored, "policy", where, dict)
72
+ if status != core.INCOMPATIBLE: # reporter 1.x lists failures only for graded trials
73
+ decision["failures"] = copy.deepcopy(_need(stored, "failures", where, list))
74
+ decision["assessor_types"] = list(_need(stored, "assessor_types", where, list))
75
+ return decision
76
+
77
+
78
+ def _summary(run, index):
79
+ where = f"assessment run {index}"
80
+ if isinstance(run, dict) and "grade" not in run:
81
+ present = [key for key in GRADE_KEYS if key in run]
82
+ if present:
83
+ raise ValueError(f"Bundle 1.1.0: {where} has '{present[0]}' but no 'grade'")
84
+ for key in UNGRADED_KEYS:
85
+ _need(run, key, where)
86
+ summary = {key: copy.deepcopy(run[key]) for key in UNGRADED_KEYS}
87
+ if "prototype" in run:
88
+ summary["prototype"] = copy.deepcopy(run["prototype"])
89
+ return summary
90
+ for key in RUN_KEYS:
91
+ _need(run, key, where)
92
+ grade = _need(run, "grade", where, str)
93
+ if grade not in core.GRADES:
94
+ raise ValueError(f"Bundle 1.1.0: {where} field 'grade' is not a known grade: {grade!r}")
95
+ interval = _need(run, "interval", where, dict)
96
+ for key in ("method", "level", "lower", "upper"):
97
+ _need(interval, key, f"{where} interval")
98
+ if interval["method"] != "wilson" or interval["level"] != 0.95:
99
+ raise ValueError(f"Bundle 1.1.0: {where} interval must be the Wilson 95% interval")
100
+ out = {k: copy.deepcopy(run[k]) for k in RUN_KEYS if k != "interval"}
101
+ out["wilson95"] = [interval["lower"], interval["upper"]]
102
+ summary = {k: out[k] for k in SUMMARY_KEYS}
103
+ # Optional. A missing key leaves the summary byte-for-byte the shape it has today.
104
+ if "reproducibility" in run:
105
+ summary["reproducibility"] = copy.deepcopy(run["reproducibility"])
106
+ return summary
107
+
108
+
109
+ def report_from_bundle(loaded, evidence_links=None):
110
+ """The report for a bundle 1.1.0, from its stored decisions; computes no grade."""
111
+ bundle = core.validate_bundle(loaded["bundle"])
112
+ if not is_assessed(bundle):
113
+ raise ValueError(f"Expected bundle {BUNDLE_VERSION}, got {bundle.get('schema_version')!r}")
114
+ assessment = _need(bundle, "assessment", "bundle", dict)
115
+ for key in ("format", "policy", "aggregation", "runs"):
116
+ _need(assessment, key, "bundle assessment")
117
+ if assessment["format"] != FORMAT:
118
+ raise ValueError(
119
+ f"Bundle 1.1.0: assessment format {assessment['format']!r} is not {FORMAT}"
120
+ )
121
+ policy = assessment["policy"]
122
+ for key in ("id", "version"):
123
+ _need(policy, key, "bundle assessment policy", str)
124
+ found = [_decision(r) for r in bundle["results"]]
125
+ if any(decision is not None for decision in found):
126
+ _need(assessment, "decisions", "bundle assessment")
127
+ listed_decisions = assessment.get("decisions") or []
128
+ stored = {d.get("result_id"): d for d in listed_decisions if isinstance(d, dict)}
129
+ for result, decision in zip(bundle["results"], found):
130
+ if decision is None:
131
+ if result["id"] in stored:
132
+ raise ValueError(
133
+ f"Bundle 1.1.0: assessment decisions list result '{result['id']}', "
134
+ "which has no decision"
135
+ )
136
+ continue
137
+ listed = stored.get(result["id"])
138
+ if listed is None:
139
+ raise ValueError(
140
+ f"Bundle 1.1.0: assessment decisions are missing result '{result['id']}'"
141
+ )
142
+ if listed.get("status") != decision["status"] or listed.get("reason") != decision["reason"]:
143
+ raise ValueError(
144
+ f"Bundle 1.1.0: result '{result['id']}' decision differs from the assessment"
145
+ )
146
+ if result["decision"]["policy"] != policy:
147
+ raise ValueError(f"Bundle 1.1.0: result '{result['id']}' decision names another policy")
148
+ if decision["status"] == core.PASS and any(
149
+ state != "verified" for state in loaded["evidence_state"].get(result["id"], {}).values()
150
+ ):
151
+ raise ValueError(
152
+ f"Bundle 1.1.0: result '{result['id']}' is stored as PASS but its evidence "
153
+ "is missing or changed"
154
+ )
155
+ report = {
156
+ "report_version": "1.0.0",
157
+ "policy": f"{policy['id']}@{policy['version']}",
158
+ "source_bundle": bundle,
159
+ "source_bundle_sha256": core.digest(bundle),
160
+ "human_contributions": {"schema_version": "1.0.0", "assessments": []},
161
+ "evidence_state": copy.deepcopy(loaded["evidence_state"]),
162
+ "groups": core.aggregate(bundle["results"]),
163
+ "decisions": [decision for decision in found if decision is not None],
164
+ }
165
+ runs = [_summary(run, i) for i, run in enumerate(assessment["runs"])]
166
+ known = {r["id"] for r in bundle["results"]}
167
+ for i, run in enumerate(runs):
168
+ unknown = [rid for rid in run["result_ids"] if rid not in known]
169
+ if unknown:
170
+ raise ValueError(
171
+ f"Bundle 1.1.0: assessment run {i} names unknown result '{unknown[0]}'"
172
+ )
173
+ # Each run is all or nothing: a graded run has a decision on every trial it names,
174
+ # and a run with no grade has none.
175
+ decided = {r["id"]: d is not None for r, d in zip(bundle["results"], found)}
176
+ for i, run in enumerate(assessment["runs"]):
177
+ graded = "grade" in run
178
+ for rid in run["result_ids"]:
179
+ if graded and not decided[rid]:
180
+ raise ValueError(
181
+ f"Bundle 1.1.0: assessment run {i} is graded but result '{rid}' has no decision"
182
+ )
183
+ if not graded and decided[rid]:
184
+ raise ValueError(
185
+ f"Bundle 1.1.0: assessment run {i} has no grade but result '{rid}' "
186
+ "has a decision"
187
+ )
188
+ if runs:
189
+ report["summaries"] = runs
190
+ if evidence_links:
191
+ report["evidence_links"] = elinks.merge(evidence_links)
192
+ return report
@@ -0,0 +1,226 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/Living-Proof-Labs/livingproof-capability-report/src/livingproof_capability_report/bundle.schema.json",
4
+ "title": "livingproof-capability-bundle",
5
+ "version": "1.1.0",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "enum": [
10
+ "1.0.0",
11
+ "1.1.0"
12
+ ]
13
+ },
14
+ "producer": {
15
+ "type": "object",
16
+ "properties": {
17
+ "id": {
18
+ "type": "string",
19
+ "minLength": 1
20
+ },
21
+ "version": {
22
+ "type": "string",
23
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
24
+ },
25
+ "commit": {
26
+ "type": "string",
27
+ "minLength": 1
28
+ }
29
+ },
30
+ "required": [
31
+ "id",
32
+ "version",
33
+ "commit"
34
+ ]
35
+ },
36
+ "results": {
37
+ "type": "array",
38
+ "minItems": 1,
39
+ "items": {
40
+ "type": "object",
41
+ "properties": {
42
+ "id": {
43
+ "type": "string",
44
+ "minLength": 1
45
+ },
46
+ "spec": {
47
+ "type": "object",
48
+ "properties": {
49
+ "repository": {
50
+ "type": "string",
51
+ "minLength": 1
52
+ },
53
+ "tag": {
54
+ "type": "string",
55
+ "pattern": "^v\\d+\\.\\d+\\.\\d+$"
56
+ },
57
+ "commit": {
58
+ "type": "string",
59
+ "pattern": "^[0-9a-f]{40}$"
60
+ },
61
+ "capability": {
62
+ "type": "string",
63
+ "minLength": 1
64
+ },
65
+ "revision": {
66
+ "type": "string",
67
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
68
+ }
69
+ },
70
+ "required": [
71
+ "repository",
72
+ "tag",
73
+ "commit",
74
+ "capability",
75
+ "revision"
76
+ ]
77
+ },
78
+ "system": {
79
+ "type": "object",
80
+ "properties": {
81
+ "id": {
82
+ "type": "string",
83
+ "minLength": 1
84
+ },
85
+ "version": {
86
+ "type": "string",
87
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
88
+ }
89
+ },
90
+ "required": [
91
+ "id",
92
+ "version"
93
+ ]
94
+ },
95
+ "environment": {
96
+ "type": "object",
97
+ "properties": {
98
+ "id": {
99
+ "type": "string",
100
+ "minLength": 1
101
+ },
102
+ "version": {
103
+ "type": "string",
104
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
105
+ }
106
+ },
107
+ "required": [
108
+ "id",
109
+ "version"
110
+ ]
111
+ },
112
+ "evidence": {
113
+ "type": "array",
114
+ "items": {
115
+ "type": "object",
116
+ "properties": {
117
+ "id": {
118
+ "type": "string",
119
+ "minLength": 1
120
+ },
121
+ "path": {
122
+ "type": "string",
123
+ "minLength": 1
124
+ },
125
+ "sha256": {
126
+ "type": "string",
127
+ "pattern": "^[0-9a-f]{64}$"
128
+ }
129
+ },
130
+ "required": [
131
+ "id",
132
+ "path",
133
+ "sha256"
134
+ ]
135
+ }
136
+ },
137
+ "assessments": {
138
+ "type": "array",
139
+ "items": {
140
+ "type": "object",
141
+ "properties": {
142
+ "id": {
143
+ "type": "string",
144
+ "minLength": 1
145
+ },
146
+ "evaluator": {
147
+ "type": "string",
148
+ "minLength": 1
149
+ },
150
+ "kind": {
151
+ "enum": [
152
+ "deterministic",
153
+ "mock-agent",
154
+ "agent",
155
+ "human"
156
+ ]
157
+ },
158
+ "version": {
159
+ "type": "string",
160
+ "pattern": "^\\d+\\.\\d+\\.\\d+$"
161
+ },
162
+ "status": {
163
+ "enum": [
164
+ "PASS",
165
+ "FAIL",
166
+ "INSUFFICIENT_EVIDENCE"
167
+ ]
168
+ },
169
+ "rationale": {
170
+ "type": "string",
171
+ "minLength": 1
172
+ },
173
+ "mandatory": {
174
+ "type": "boolean"
175
+ },
176
+ "evidence_ids": {
177
+ "type": "array",
178
+ "items": {
179
+ "type": "string",
180
+ "minLength": 1
181
+ },
182
+ "uniqueItems": true
183
+ },
184
+ "provenance": {
185
+ "type": "object"
186
+ }
187
+ },
188
+ "required": [
189
+ "id",
190
+ "evaluator",
191
+ "kind",
192
+ "version",
193
+ "status",
194
+ "rationale",
195
+ "mandatory",
196
+ "evidence_ids",
197
+ "provenance"
198
+ ]
199
+ }
200
+ },
201
+ "provenance": {
202
+ "type": "object"
203
+ },
204
+ "original_result": {
205
+ "type": "object"
206
+ }
207
+ },
208
+ "required": [
209
+ "id",
210
+ "spec",
211
+ "system",
212
+ "environment",
213
+ "evidence",
214
+ "assessments",
215
+ "provenance",
216
+ "original_result"
217
+ ]
218
+ }
219
+ }
220
+ },
221
+ "required": [
222
+ "schema_version",
223
+ "producer",
224
+ "results"
225
+ ]
226
+ }