livingproof-evaluator-run 1.13.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.
@@ -0,0 +1,11 @@
1
+ .venv/
2
+ .build/
3
+ site/
4
+ __pycache__/
5
+ .livingproof-evaluator/
6
+ artifacts/
7
+ dist/
8
+ *.egg-info/
9
+ .ruff_cache/
10
+ .pytest_cache/
11
+ .coverage
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,40 @@
1
+ Metadata-Version: 2.5
2
+ Name: livingproof-evaluator-run
3
+ Version: 1.13.0
4
+ Summary: Evaluates run infrastructure and evidence suitability for judging robot capabilities.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Python: <3.13,>=3.12
8
+ Requires-Dist: mcap==1.6.0
9
+ Description-Content-Type: text/markdown
10
+
11
+ # livingproof-evaluator-run
12
+
13
+ Run integrity grows one check at a time. Every time we lose time to something that wasn't the robot, the follow-up is a new integrity check, plus the run that would have caught it.
14
+
15
+ This repository implements the [Run Integrity](https://github.com/Living-Proof-Labs/livingproof-evaluator/blob/v1.12.0/docs/run-integrity.md) evaluator. It gives a separate opinion on whether anything besides the robot shaped a run. It invalidates the run; it does not grade the robot.
16
+
17
+ The first slice is one check, `completeness` 1.1.0: planned trial count versus observation files present, and `trials.results[].sha256` matching, on `livingproof-hallway-evidence/2.0.0`. With `--media` it also reads the recordings `media.json` lists and reports one that is missing, truncated or empty (`missing-recording`, `truncated-recording`, `empty-recording`); it owns truncation, so `recording` does not judge such a file. It does not detect a `timeout` or a `crash` from an evidence manifest, which records neither; on a `livingproof-evaluator-request` a trial whose `termination` is `timeout` or `crash` is an `ended-by-timeout` or `ended-by-crash` finding.
18
+
19
+ ```bash
20
+ python -m livingproof_evaluator_run evidence/manifest.json --out result.json
21
+ ```
22
+
23
+ The implementation descriptor is [`livingproof-evaluator.json`](livingproof-evaluator.json). A loader pins `Living-Proof-Labs/livingproof-evaluator-run@<tag>/livingproof-evaluator.json`.
24
+
25
+ `pins` 1.1.0 compares the pins the verification lock declares with what the run recorded: world, configuration and runner today. Specs and verifier are listed in `not_checked` until the evidence records them. See [the checks](docs/index.md#checks).
26
+
27
+ `plan-conformance` 1.1.0 checks that the trials that ran are the trials that were planned: the plan, `trials.count`, the number of `trials.results` entries and the lock's plan agree on the trial count and the command speed, and the indexes are exactly 1 to N with each path `trials/trial-NN.json` for its own index. A run whose preconditions are unmet is not applicable. See [the checks](docs/index.md#checks).
28
+
29
+ `termination` 1.1.0 checks that every trial that ended on its own records a stop reason the plan allows. The reason is the `end` in the trial's observation file, mapped to the contract's words (`crossed_exit` is `mission-done`, `left_hallway` and `left_world` are `left-world`, `time_limit` is `time-limit`, `non_finite_state` is `simulation-broken`), and it must agree with `trials.results[].outcome` in the manifest. The plan's allowed list is `plan.allowed_stop_reasons`, else the lock's plan, else a default that leaves out `simulation-broken`, which is never allowed. A timeout or crash is `completeness`'s finding, and `termination` only refers to it. It does not detect a crash or a killed runner from an evidence manifest: nothing records one yet (livingproof-sim-mujoco#105, capability-verifier#155). See [the checks](docs/index.md#checks).
30
+
31
+ `recording` 1.2.0 checks that each recording that is present is a usable MCAP file: complete, with every required channel carrying messages, no timestamp that goes backwards, no gap over the limit, and the size, sha256 and observation digest that `media.json` and the run evidence record. The recordings are the media job's artifact, so they are a separate input: `--media DIR` (a directory with `media.json` and `mcap/`). Without it there is no media and the check is not applicable. A recording that would decompress past a size limit (32 MiB a chunk, 2 GiB in all, 50,000,000 records, 100,000 chunks) is not read, so a small hostile file cannot exhaust the evaluator. It is still present, not truncated: `recording` judges it and fails closed with `recording-over-limit`, naming the limit and its value, and `completeness` reports nothing. **The gap limit has no default.** It must be declared in the evidence (`plan.recording.max_gap_seconds`), and without one the check is not applicable and says so. Nothing declares one yet, and capability-verifier#156 has not yet given the Run Integrity job the recordings, so on a real run today the check is not applicable. See [the checks](docs/index.md#checks).
32
+
33
+ The result is a `livingproof-evaluator-result/1.2.0` document. When no check applies the run is `INCONCLUSIVE` (status and conclusion), `success` is false and there is no `percentage`: nothing was judged, so it is not graded. Checks that do not compare everything list what they left out in `not_checked`. A `livingproof-evaluator-request` whose recording state contradicts its evidence is malformed: the command exits 2 and writes no result. A failed check reports test-system status `ERROR` and conclusion `INCONCLUSIVE`. It never changes a robot grade.
34
+
35
+ **Documentation** — [manual source](docs/index.md)
36
+ (publication pending; no verified live manual yet).
37
+
38
+ [Documentation home](https://docs.livingprooflabs.com/) ·
39
+ [Build and verification](docs/verification.md) ·
40
+ [Contribute and license](docs/contribute.md)
@@ -0,0 +1,30 @@
1
+ # livingproof-evaluator-run
2
+
3
+ Run integrity grows one check at a time. Every time we lose time to something that wasn't the robot, the follow-up is a new integrity check, plus the run that would have caught it.
4
+
5
+ This repository implements the [Run Integrity](https://github.com/Living-Proof-Labs/livingproof-evaluator/blob/v1.12.0/docs/run-integrity.md) evaluator. It gives a separate opinion on whether anything besides the robot shaped a run. It invalidates the run; it does not grade the robot.
6
+
7
+ The first slice is one check, `completeness` 1.1.0: planned trial count versus observation files present, and `trials.results[].sha256` matching, on `livingproof-hallway-evidence/2.0.0`. With `--media` it also reads the recordings `media.json` lists and reports one that is missing, truncated or empty (`missing-recording`, `truncated-recording`, `empty-recording`); it owns truncation, so `recording` does not judge such a file. It does not detect a `timeout` or a `crash` from an evidence manifest, which records neither; on a `livingproof-evaluator-request` a trial whose `termination` is `timeout` or `crash` is an `ended-by-timeout` or `ended-by-crash` finding.
8
+
9
+ ```bash
10
+ python -m livingproof_evaluator_run evidence/manifest.json --out result.json
11
+ ```
12
+
13
+ The implementation descriptor is [`livingproof-evaluator.json`](livingproof-evaluator.json). A loader pins `Living-Proof-Labs/livingproof-evaluator-run@<tag>/livingproof-evaluator.json`.
14
+
15
+ `pins` 1.1.0 compares the pins the verification lock declares with what the run recorded: world, configuration and runner today. Specs and verifier are listed in `not_checked` until the evidence records them. See [the checks](docs/index.md#checks).
16
+
17
+ `plan-conformance` 1.1.0 checks that the trials that ran are the trials that were planned: the plan, `trials.count`, the number of `trials.results` entries and the lock's plan agree on the trial count and the command speed, and the indexes are exactly 1 to N with each path `trials/trial-NN.json` for its own index. A run whose preconditions are unmet is not applicable. See [the checks](docs/index.md#checks).
18
+
19
+ `termination` 1.1.0 checks that every trial that ended on its own records a stop reason the plan allows. The reason is the `end` in the trial's observation file, mapped to the contract's words (`crossed_exit` is `mission-done`, `left_hallway` and `left_world` are `left-world`, `time_limit` is `time-limit`, `non_finite_state` is `simulation-broken`), and it must agree with `trials.results[].outcome` in the manifest. The plan's allowed list is `plan.allowed_stop_reasons`, else the lock's plan, else a default that leaves out `simulation-broken`, which is never allowed. A timeout or crash is `completeness`'s finding, and `termination` only refers to it. It does not detect a crash or a killed runner from an evidence manifest: nothing records one yet (livingproof-sim-mujoco#105, capability-verifier#155). See [the checks](docs/index.md#checks).
20
+
21
+ `recording` 1.2.0 checks that each recording that is present is a usable MCAP file: complete, with every required channel carrying messages, no timestamp that goes backwards, no gap over the limit, and the size, sha256 and observation digest that `media.json` and the run evidence record. The recordings are the media job's artifact, so they are a separate input: `--media DIR` (a directory with `media.json` and `mcap/`). Without it there is no media and the check is not applicable. A recording that would decompress past a size limit (32 MiB a chunk, 2 GiB in all, 50,000,000 records, 100,000 chunks) is not read, so a small hostile file cannot exhaust the evaluator. It is still present, not truncated: `recording` judges it and fails closed with `recording-over-limit`, naming the limit and its value, and `completeness` reports nothing. **The gap limit has no default.** It must be declared in the evidence (`plan.recording.max_gap_seconds`), and without one the check is not applicable and says so. Nothing declares one yet, and capability-verifier#156 has not yet given the Run Integrity job the recordings, so on a real run today the check is not applicable. See [the checks](docs/index.md#checks).
22
+
23
+ The result is a `livingproof-evaluator-result/1.2.0` document. When no check applies the run is `INCONCLUSIVE` (status and conclusion), `success` is false and there is no `percentage`: nothing was judged, so it is not graded. Checks that do not compare everything list what they left out in `not_checked`. A `livingproof-evaluator-request` whose recording state contradicts its evidence is malformed: the command exits 2 and writes no result. A failed check reports test-system status `ERROR` and conclusion `INCONCLUSIVE`. It never changes a robot grade.
24
+
25
+ **Documentation** — [manual source](docs/index.md)
26
+ (publication pending; no verified live manual yet).
27
+
28
+ [Documentation home](https://docs.livingprooflabs.com/) ·
29
+ [Build and verification](docs/verification.md) ·
30
+ [Contribute and license](docs/contribute.md)
@@ -0,0 +1,54 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ [project]
4
+ name = "livingproof-evaluator-run"
5
+ dynamic = ["version"]
6
+ description = "Evaluates run infrastructure and evidence suitability for judging robot capabilities."
7
+ readme = "README.md"
8
+ license = "Apache-2.0"
9
+ license-files = ["LICENSE"]
10
+ requires-python = ">=3.12,<3.13"
11
+ dependencies = [
12
+ "mcap==1.6.0",
13
+ ]
14
+
15
+ [dependency-groups]
16
+ dev = [
17
+ "defusedxml==0.7.1",
18
+ "jsonschema==4.26.0",
19
+ "pytest==9.2.0",
20
+ "ruff==0.14.2",
21
+ ]
22
+ docs = [
23
+ "zensical==0.0.73",
24
+ ]
25
+
26
+ [build-system]
27
+ requires = ["hatchling==1.33.0", "hatch-vcs==0.5.0"]
28
+ build-backend = "hatchling.build"
29
+
30
+ [tool.hatch.version]
31
+ source = "vcs"
32
+
33
+ [tool.hatch.version.raw-options]
34
+ local_scheme = "no-local-version"
35
+ fallback_version = "0.1.dev0"
36
+
37
+ # Build only from project-owned package source, not from checkout test recordings.
38
+ [tool.hatch.build.targets.sdist]
39
+ only-include = ["src/livingproof_evaluator_run", "pyproject.toml", "README.md", "LICENSE"]
40
+
41
+ [tool.hatch.build.targets.wheel]
42
+ packages = ["src/livingproof_evaluator_run"]
43
+
44
+ [tool.uv]
45
+ default-groups = ["dev", "docs"]
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
49
+ addopts = "-ra"
50
+
51
+ [tool.ruff]
52
+ line-length = 100
53
+ target-version = "py312"
54
+ src = ["src", "tests"]
@@ -0,0 +1,13 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ """Run Integrity evaluator: test-system status for a verification run.
4
+
5
+ Completeness 1.1.0 compares the planned trial count with the observation files present
6
+ and trials.results[].sha256, and with media the recordings media.json lists. Pins,
7
+ plan-conformance, termination and recording (all 1.1.0) follow; the ones that do not compare
8
+ everything list what they left out in not_checked. It never grades the robot.
9
+ """
10
+
11
+ from livingproof_evaluator_run.evaluate import evaluate, evaluate_evidence
12
+
13
+ __all__ = ["evaluate", "evaluate_evidence"]
@@ -0,0 +1,42 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ """Write a Run Integrity result for one evidence manifest or evaluator request.
4
+
5
+ python -m livingproof_evaluator_run evidence/manifest.json --out result.json
6
+ python -m livingproof_evaluator_run evidence/manifest.json --media media --out result.json
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ from pathlib import Path
13
+
14
+ from livingproof_evaluator_run.evaluate import evaluate
15
+
16
+
17
+ def main(argv: list[str] | None = None) -> int:
18
+ parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
19
+ parser.add_argument(
20
+ "source", type=Path, help="Evidence manifest or livingproof-evaluator-request"
21
+ )
22
+ parser.add_argument(
23
+ "--out",
24
+ type=Path,
25
+ required=True,
26
+ help="Path for the livingproof-evaluator-result/1.2.0 document",
27
+ )
28
+ parser.add_argument(
29
+ "--media",
30
+ type=Path,
31
+ default=None,
32
+ help=(
33
+ "Directory with media.json and mcap/ (the media job's artifact); "
34
+ "without it the recording check is not applicable"
35
+ ),
36
+ )
37
+ args = parser.parse_args(argv)
38
+ return evaluate(args.source, args.out, args.media)
39
+
40
+
41
+ if __name__ == "__main__":
42
+ raise SystemExit(main())
@@ -0,0 +1,90 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ """completeness 1.1.0: every planned trial has a recording and observations, and ended on its own.
4
+
5
+ The contract (livingproof-evaluator ``schema/integrity/checks/completeness.schema.json`` and
6
+ ``docs/run-integrity.md``, v1.2.0) fixes the rule. A planned trial with no evidence is
7
+ ``missing-trial``. A trial whose termination is ``timeout`` or ``crash`` is ``ended-by-timeout`` or
8
+ ``ended-by-crash`` and has no other finding: it is the one report of that ending. Otherwise the
9
+ trial's recording and its observations are each missing, truncated or empty, or present, and the
10
+ three that are not are ``missing-``, ``truncated-`` and ``empty-`` ``recording`` or
11
+ ``observations`` findings. ``percentage`` is 100 times the complete planned trials over the
12
+ planned trials.
13
+
14
+ *The recording* is the one ``media.json`` lists for the trial on an evidence manifest (read with
15
+ ``recording.read_media``), and ``recording.state`` on a request. A file with no valid footer is
16
+ ``truncated``, and this check owns it: ``recording`` does not judge it and lists the trial as
17
+ ``not-present``, so a truncation is reported once. A listed recording that is missing makes the run
18
+ incomplete, so a run with one of three listed recordings missing is never COMPLETED and 100. A
19
+ trial ``media.json`` does not list has no recording to read here.
20
+
21
+ From 1.1.0 the check follows plan-conformance's applicability: when the run's preconditions were
22
+ unmet it ran no trials, the check is not applicable and no planned trial is reported as missing.
23
+ Version 1.0.0, which stays valid, is always applicable; ``version="1.0.0"`` selects that.
24
+ """
25
+
26
+ from __future__ import annotations
27
+
28
+ from livingproof_evaluator_run import plan_conformance
29
+
30
+ COMPLETENESS_ID = "completeness"
31
+ COMPLETENESS_VERSION = "1.1.0"
32
+ PREVIOUS_VERSIONS = ("1.0.0",)
33
+ SUCCESS_COPY = "Every planned trial has its observation file."
34
+
35
+ # The category and the words for a recording or observations that is not present.
36
+ _RECORDING = {
37
+ "missing": ("missing-recording", "Trial {id} has no recording."),
38
+ "truncated": ("truncated-recording", "Trial {id} has a truncated recording."),
39
+ "empty": ("empty-recording", "Trial {id} has an empty recording."),
40
+ }
41
+ _OBSERVATIONS = {
42
+ "missing": ("missing-observations", "Planned trial {id} has no observations."),
43
+ "truncated": ("truncated-observations", "Trial {id} has truncated observations."),
44
+ "empty": ("empty-observations", "Trial {id} has empty observations."),
45
+ }
46
+
47
+
48
+ def finding(category: str, trial_id: str, summary: str) -> dict:
49
+ return {
50
+ "category": category,
51
+ "classification": "test_system",
52
+ "summary": summary,
53
+ "trial_id": trial_id,
54
+ }
55
+
56
+
57
+ def recording_finding(trial_id: str, state: object) -> dict | None:
58
+ """The finding for a recording that is ``missing``, ``truncated`` or ``empty``, else None.
59
+
60
+ A recording the reader refused for its size (``mcap_reader.Caps``) is ``present``: ``recording``
61
+ reports it as ``recording-over-limit`` (livingproof-evaluator#42), not as truncation."""
62
+ found = _RECORDING.get(state) if isinstance(state, str) else None
63
+ if not found:
64
+ return None
65
+ return finding(found[0], trial_id, found[1].format(id=trial_id))
66
+
67
+
68
+ def observations_finding(trial_id: str, state: object) -> dict | None:
69
+ """The finding for observations that are ``missing``, ``truncated`` or ``empty``, else None."""
70
+ found = _OBSERVATIONS.get(state) if isinstance(state, str) else None
71
+ return finding(found[0], trial_id, found[1].format(id=trial_id)) if found else None
72
+
73
+
74
+ def applicable_for_request(integrity: dict, version: str = COMPLETENESS_VERSION) -> bool:
75
+ """False when ``evidence['plan-conformance'].preconditions.met`` is false: the run ran no
76
+ trials. 1.0.0 was always applicable."""
77
+ if version == "1.0.0":
78
+ return True
79
+ evidence = integrity.get("evidence") if isinstance(integrity, dict) else None
80
+ conformance = evidence.get("plan-conformance") if isinstance(evidence, dict) else None
81
+ preconditions = conformance.get("preconditions") if isinstance(conformance, dict) else None
82
+ met = preconditions.get("met", True) if isinstance(preconditions, dict) else True
83
+ return met is not False
84
+
85
+
86
+ def applicable_for_evidence(manifest: dict, version: str = COMPLETENESS_VERSION) -> bool:
87
+ """False when the manifest records a required precondition that was not met."""
88
+ if version == "1.0.0":
89
+ return True
90
+ return not plan_conformance._unmet(manifest.get("preconditions"))