livingproof-verifier 6.3.1__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.
- capability_verifier/__init__.py +1 -0
- capability_verifier/bundle_hashes.py +118 -0
- capability_verifier/collect.py +798 -0
- capability_verifier/definition.py +932 -0
- capability_verifier/evaluator_contract.py +7 -0
- capability_verifier/evaluators.py +1181 -0
- capability_verifier/evidence_lock.py +263 -0
- capability_verifier/judgments.py +78 -0
- capability_verifier/livingproof-evidence-ending-0.1.schema.json +69 -0
- capability_verifier/livingproof-verification-refusal-0.1.schema.json +36 -0
- capability_verifier/plugin.py +21 -0
- capability_verifier/refusal.py +227 -0
- capability_verifier/registry_runner.py +180 -0
- capability_verifier/repin.py +279 -0
- capability_verifier/resolved_pins.py +213 -0
- capability_verifier/run.py +304 -0
- capability_verifier/specs_ref.py +66 -0
- livingproof_verifier-6.3.1.dist-info/METADATA +90 -0
- livingproof_verifier-6.3.1.dist-info/RECORD +23 -0
- livingproof_verifier-6.3.1.dist-info/WHEEL +5 -0
- livingproof_verifier-6.3.1.dist-info/entry_points.txt +2 -0
- livingproof_verifier-6.3.1.dist-info/licenses/LICENSE +73 -0
- livingproof_verifier-6.3.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
"""Every sha256 a run bundle declares resolves (capability-verifier#86).
|
|
3
|
+
|
|
4
|
+
An evidence folder's hashes are resolved by the pinned livingproof-sim-mujoco
|
|
5
|
+
``evidence.unresolved_hashes`` (v3.2.5, sim#74): artifact hashes against the file at the
|
|
6
|
+
sibling ``path``, ``trajectory_sha256`` recomputed from the trial file with
|
|
7
|
+
``evidence.trajectory_sha256_of`` (the observation's ``trace`` as compact, key-sorted
|
|
8
|
+
JSON), and pinned source inputs by name. No formula is copied here.
|
|
9
|
+
|
|
10
|
+
The sim catalog does not document three fields that released bundles carry. This module
|
|
11
|
+
documents them, and nothing else is skipped:
|
|
12
|
+
|
|
13
|
+
- ``lock.content.definition.sha256``: ``source``. The verification-lock 0.2.0 digest of
|
|
14
|
+
the robot's definition file (``definition.lock``), which is not in the evidence folder.
|
|
15
|
+
- ``lock.content.overridden_robot_lock.sha256``: ``source``. The robot
|
|
16
|
+
``verification.lock.json`` a caller lock replaced (``evidence_lock``).
|
|
17
|
+
- ``trials.reproducibility.finding.trajectory_sha256``: ``copy``. The sim's disagreement
|
|
18
|
+
finding lists each trial's ``trajectory_sha256`` in result order, so it resolves when it
|
|
19
|
+
equals ``trials.results[].trajectory_sha256`` (each of which resolves by recompute).
|
|
20
|
+
|
|
21
|
+
``unresolved_report`` does the same for the verifier's ``verification.json``: a hash with
|
|
22
|
+
a sibling ``path`` is the evidence file at that path, and a repeat row (``index``) copies
|
|
23
|
+
the evidence result with that index.
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
import hashlib
|
|
27
|
+
import json
|
|
28
|
+
from pathlib import Path
|
|
29
|
+
|
|
30
|
+
from livingproof_sim_mujoco import evidence
|
|
31
|
+
|
|
32
|
+
VERIFIER_DECLARED_HASHES = {
|
|
33
|
+
"manifest.json": {
|
|
34
|
+
"lock.content.definition.sha256": "source",
|
|
35
|
+
"lock.content.overridden_robot_lock.sha256": "source",
|
|
36
|
+
"trials.reproducibility.finding.trajectory_sha256": "copy",
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _hash_fields(node, key: str = ""):
|
|
42
|
+
"""``(key, value, parent)`` for every field whose name contains ``sha256``."""
|
|
43
|
+
if isinstance(node, dict):
|
|
44
|
+
for name, value in node.items():
|
|
45
|
+
here = f"{key}.{name}" if key else name
|
|
46
|
+
if "sha256" in name:
|
|
47
|
+
yield here, value, node
|
|
48
|
+
yield from _hash_fields(value, here)
|
|
49
|
+
elif isinstance(node, list):
|
|
50
|
+
for index, value in enumerate(node):
|
|
51
|
+
yield from _hash_fields(value, f"{key}[{index}]")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _results(folder: Path) -> list:
|
|
55
|
+
manifest = json.loads((folder / "manifest.json").read_text(encoding="utf-8"))
|
|
56
|
+
trials = manifest.get("trials") if isinstance(manifest, dict) else None
|
|
57
|
+
results = trials.get("results") if isinstance(trials, dict) else None
|
|
58
|
+
return results if isinstance(results, list) else []
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def unresolved(folder: Path) -> list[str]:
|
|
62
|
+
"""One message per hash in evidence ``folder`` that does not resolve. Empty when all do."""
|
|
63
|
+
folder = Path(folder)
|
|
64
|
+
verifier = {}
|
|
65
|
+
for item in evidence.declared_hashes(folder):
|
|
66
|
+
if item["covers"] is None:
|
|
67
|
+
covers = VERIFIER_DECLARED_HASHES.get(item["file"], {}).get(item["key"])
|
|
68
|
+
if covers is not None:
|
|
69
|
+
verifier[f"{item['file']} {item['key']}"] = (covers, item)
|
|
70
|
+
problems = [
|
|
71
|
+
message
|
|
72
|
+
for message in evidence.unresolved_hashes(folder)
|
|
73
|
+
if not any(message.startswith(f"{where} ") for where in verifier)
|
|
74
|
+
]
|
|
75
|
+
for where, (covers, item) in verifier.items():
|
|
76
|
+
if covers != "copy":
|
|
77
|
+
continue
|
|
78
|
+
trial_hashes = [r.get("trajectory_sha256") for r in _results(folder)]
|
|
79
|
+
if item["sha256"] != trial_hashes:
|
|
80
|
+
problems.append(
|
|
81
|
+
f"{where} is {item['sha256']!r} but trials.results[].trajectory_sha256 "
|
|
82
|
+
f"is {trial_hashes!r}."
|
|
83
|
+
)
|
|
84
|
+
return problems
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def report_hashes(report: Path) -> list[tuple[str, object, dict]]:
|
|
88
|
+
"""``(key, value, parent)`` for every sha256 field in a ``verification.json``."""
|
|
89
|
+
return list(_hash_fields(json.loads(Path(report).read_text(encoding="utf-8"))))
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def unresolved_report(report: Path, folder: Path) -> list[str]:
|
|
93
|
+
"""Hashes in ``report`` that are neither an evidence file in ``folder`` nor a copy."""
|
|
94
|
+
report, folder = Path(report), Path(folder)
|
|
95
|
+
by_index = {r.get("index"): r for r in _results(folder) if isinstance(r, dict)}
|
|
96
|
+
problems = []
|
|
97
|
+
for key, value, parent in report_hashes(report):
|
|
98
|
+
where = f"{report.name} {key}"
|
|
99
|
+
name = key.rsplit(".", 1)[-1]
|
|
100
|
+
rel = parent.get("path")
|
|
101
|
+
if isinstance(rel, str):
|
|
102
|
+
target = folder / rel
|
|
103
|
+
if not target.is_file():
|
|
104
|
+
problems.append(f"{where}: its path {rel!r} is not a file in the evidence.")
|
|
105
|
+
continue
|
|
106
|
+
actual = hashlib.sha256(target.read_bytes()).hexdigest()
|
|
107
|
+
if actual != value:
|
|
108
|
+
problems.append(f"{where} is {value} but the file {rel} gives {actual}.")
|
|
109
|
+
elif "index" in parent:
|
|
110
|
+
source = by_index.get(parent["index"])
|
|
111
|
+
if source is None or source.get(name) != value:
|
|
112
|
+
got = None if source is None else source.get(name)
|
|
113
|
+
problems.append(
|
|
114
|
+
f"{where} is {value} but evidence result {parent['index']} has {got}."
|
|
115
|
+
)
|
|
116
|
+
else:
|
|
117
|
+
problems.append(f"{where} names no evidence file and copies no evidence result.")
|
|
118
|
+
return problems
|