liveframe 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.
- liveframe-0.1.0/.gitignore +36 -0
- liveframe-0.1.0/LICENSE +194 -0
- liveframe-0.1.0/PKG-INFO +61 -0
- liveframe-0.1.0/README.md +38 -0
- liveframe-0.1.0/pyproject.toml +40 -0
- liveframe-0.1.0/src/liveframe/__init__.py +11 -0
- liveframe-0.1.0/src/liveframe/cli.py +227 -0
- liveframe-0.1.0/tests/test_cli.py +133 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
.pytest_cache/
|
|
6
|
+
.mypy_cache/
|
|
7
|
+
.ruff_cache/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.egg-info/
|
|
11
|
+
release/
|
|
12
|
+
|
|
13
|
+
# LaTeX build scratch files
|
|
14
|
+
paper/arxiv/*.aux
|
|
15
|
+
paper/arxiv/*.blg
|
|
16
|
+
paper/arxiv/*.log
|
|
17
|
+
paper/arxiv/*.out
|
|
18
|
+
|
|
19
|
+
# Large or machine-local artifacts
|
|
20
|
+
outputs/
|
|
21
|
+
weights/
|
|
22
|
+
checkpoints/
|
|
23
|
+
third_party/
|
|
24
|
+
artifacts/h100-holdout-results/
|
|
25
|
+
artifacts/mlx-holdout-results/
|
|
26
|
+
artifacts/shared-rolling-noise.v1/
|
|
27
|
+
*.pt
|
|
28
|
+
*.pth
|
|
29
|
+
*.safetensors
|
|
30
|
+
*.mp4
|
|
31
|
+
*.mov
|
|
32
|
+
*.mkv
|
|
33
|
+
|
|
34
|
+
# Runtime state
|
|
35
|
+
.liveframe/
|
|
36
|
+
.claude/settings.local.json
|
liveframe-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
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 the
|
|
13
|
+
copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other
|
|
16
|
+
entities that control, are controlled by, or are under common control
|
|
17
|
+
with that entity. For the purposes of this definition, "control" means
|
|
18
|
+
(i) the power, direct or indirect, to cause the direction or management
|
|
19
|
+
of such entity, whether by contract or otherwise, or (ii) ownership of
|
|
20
|
+
fifty percent (50%) or more of the outstanding shares, or (iii)
|
|
21
|
+
beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
24
|
+
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 source,
|
|
28
|
+
and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but not
|
|
32
|
+
limited to compiled object code, generated documentation, and conversions
|
|
33
|
+
to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or Object
|
|
36
|
+
form, made available under the License, as indicated by a copyright
|
|
37
|
+
notice that is included in or attached to the work (an example is
|
|
38
|
+
provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object form,
|
|
41
|
+
that is based on (or derived from) the Work and for which the editorial
|
|
42
|
+
revisions, annotations, elaborations, or other modifications represent,
|
|
43
|
+
as a whole, an original work of authorship. For the purposes of this
|
|
44
|
+
License, Derivative Works shall not include works that remain separable
|
|
45
|
+
from, or merely link (or bind by name) to the interfaces of, the Work and
|
|
46
|
+
Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including the original
|
|
49
|
+
version of the Work and any modifications or additions to that Work or
|
|
50
|
+
Derivative Works thereof, that is intentionally submitted to Licensor for
|
|
51
|
+
inclusion in the Work by the copyright owner or by an individual or Legal
|
|
52
|
+
Entity authorized to submit on behalf of the copyright owner. For the
|
|
53
|
+
purposes of this definition, "submitted" means any form of electronic,
|
|
54
|
+
verbal, or written communication sent to the Licensor or its
|
|
55
|
+
representatives, including but not limited to communication on electronic
|
|
56
|
+
mailing lists, source code control systems, and issue tracking systems
|
|
57
|
+
that are managed by, or on behalf of, the Licensor for the purpose of
|
|
58
|
+
discussing and improving the Work, but excluding communication that is
|
|
59
|
+
conspicuously marked or otherwise designated in writing by the copyright
|
|
60
|
+
owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on
|
|
63
|
+
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 this
|
|
67
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
68
|
+
non-exclusive, no-charge, royalty-free, irrevocable copyright license to
|
|
69
|
+
reproduce, prepare Derivative Works of, publicly display, publicly
|
|
70
|
+
perform, sublicense, and distribute the Work and such Derivative Works in
|
|
71
|
+
Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
74
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
75
|
+
non-exclusive, no-charge, royalty-free, irrevocable (except as stated in
|
|
76
|
+
this section) patent license to make, have made, use, offer to sell, sell,
|
|
77
|
+
import, and otherwise transfer the Work, where such license applies only
|
|
78
|
+
to those patent claims licensable by such Contributor that are
|
|
79
|
+
necessarily infringed by their Contribution(s) alone or by combination of
|
|
80
|
+
their Contribution(s) with the Work to which such Contribution(s) was
|
|
81
|
+
submitted. If You institute patent litigation against any entity
|
|
82
|
+
(including a cross-claim or counterclaim in a lawsuit) alleging that the
|
|
83
|
+
Work or a Contribution incorporated within the Work constitutes direct or
|
|
84
|
+
contributory patent infringement, then any patent licenses granted to You
|
|
85
|
+
under this License for that Work shall terminate as of the date such
|
|
86
|
+
litigation is filed.
|
|
87
|
+
|
|
88
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or
|
|
89
|
+
Derivative Works thereof in any medium, with or without modifications, and
|
|
90
|
+
in Source or Object form, provided that You meet the following conditions:
|
|
91
|
+
|
|
92
|
+
(a) You must give any other recipients of the Work or Derivative Works a
|
|
93
|
+
copy of this License; and
|
|
94
|
+
|
|
95
|
+
(b) You must cause any modified files to carry prominent notices stating
|
|
96
|
+
that You changed the files; and
|
|
97
|
+
|
|
98
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
99
|
+
distribute, all copyright, patent, trademark, and attribution notices
|
|
100
|
+
from the Source form of the Work, excluding those notices that do not
|
|
101
|
+
pertain to any part of the Derivative Works; and
|
|
102
|
+
|
|
103
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
+
distribution, then any Derivative Works that You distribute must
|
|
105
|
+
include a readable copy of the attribution notices contained within
|
|
106
|
+
such NOTICE file, excluding those notices that do not pertain to any
|
|
107
|
+
part of the Derivative Works, in at least one of the following places:
|
|
108
|
+
within a NOTICE text file distributed as part of the Derivative Works;
|
|
109
|
+
within the Source form or documentation, if provided along with the
|
|
110
|
+
Derivative Works; or, within a display generated by the Derivative
|
|
111
|
+
Works, if and wherever such third-party notices normally appear. The
|
|
112
|
+
contents of the NOTICE file are for informational purposes only and
|
|
113
|
+
do not modify the License. You may add Your own attribution notices
|
|
114
|
+
within Derivative Works that You distribute, alongside or as an
|
|
115
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
116
|
+
additional attribution notices cannot be construed as modifying the
|
|
117
|
+
License.
|
|
118
|
+
|
|
119
|
+
You may add Your own copyright statement to Your modifications and may
|
|
120
|
+
provide additional or different license terms and conditions for use,
|
|
121
|
+
reproduction, or distribution of Your modifications, or for any such
|
|
122
|
+
Derivative Works as a whole, provided Your use, reproduction, and
|
|
123
|
+
distribution of the Work otherwise complies with the conditions stated in
|
|
124
|
+
this License.
|
|
125
|
+
|
|
126
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any
|
|
127
|
+
Contribution intentionally submitted for inclusion in the Work by You to
|
|
128
|
+
the Licensor shall be under the terms and conditions of this License,
|
|
129
|
+
without any additional terms or conditions. Notwithstanding the above,
|
|
130
|
+
nothing herein shall supersede or modify the terms of any separate license
|
|
131
|
+
agreement you may have executed with Licensor regarding such
|
|
132
|
+
Contributions.
|
|
133
|
+
|
|
134
|
+
6. Trademarks. This License does not grant permission to use the trade names,
|
|
135
|
+
trademarks, service marks, or product names of the Licensor, except as
|
|
136
|
+
required for reasonable and customary use in describing the origin of the
|
|
137
|
+
Work and reproducing the content of the NOTICE file.
|
|
138
|
+
|
|
139
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
|
|
140
|
+
writing, Licensor provides the Work (and each Contributor provides its
|
|
141
|
+
Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
|
142
|
+
ANY KIND, either express or implied, including, without limitation, any
|
|
143
|
+
warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or
|
|
144
|
+
FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
|
|
145
|
+
determining the appropriateness of using or redistributing the Work and
|
|
146
|
+
assume any risks associated with Your exercise of permissions under this
|
|
147
|
+
License.
|
|
148
|
+
|
|
149
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in
|
|
150
|
+
tort (including negligence), contract, or otherwise, unless required by
|
|
151
|
+
applicable law (such as deliberate and grossly negligent acts) or agreed
|
|
152
|
+
to in writing, shall any Contributor be liable to You for damages,
|
|
153
|
+
including any direct, indirect, special, incidental, or consequential
|
|
154
|
+
damages of any character arising as a result of this License or out of the
|
|
155
|
+
use or inability to use the Work (including but not limited to damages for
|
|
156
|
+
loss of goodwill, work stoppage, computer failure or malfunction, or any
|
|
157
|
+
and all other commercial damages or losses), even if such Contributor has
|
|
158
|
+
been advised of the possibility of such damages.
|
|
159
|
+
|
|
160
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work
|
|
161
|
+
or Derivative Works thereof, You may choose to offer, and charge a fee for,
|
|
162
|
+
acceptance of support, warranty, indemnity, or other liability obligations
|
|
163
|
+
and/or rights consistent with this License. However, in accepting such
|
|
164
|
+
obligations, You may act only on Your own behalf and on Your sole
|
|
165
|
+
responsibility, not on behalf of any other Contributor, and only if You
|
|
166
|
+
agree to indemnify, defend, and hold each Contributor harmless for any
|
|
167
|
+
liability incurred by, or claims asserted against, such Contributor by
|
|
168
|
+
reason of your accepting any such warranty or additional liability.
|
|
169
|
+
|
|
170
|
+
END OF TERMS AND CONDITIONS
|
|
171
|
+
|
|
172
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
173
|
+
|
|
174
|
+
To apply the Apache License to your work, attach the following boilerplate
|
|
175
|
+
notice, with the fields enclosed by brackets "[]" replaced with your own
|
|
176
|
+
identifying information. (Don't include the brackets!) The text should be
|
|
177
|
+
enclosed in the appropriate comment syntax for the file format. We also
|
|
178
|
+
recommend that a file or class name and description of purpose be included
|
|
179
|
+
on the same "printed page" as the copyright notice for easier
|
|
180
|
+
identification within third-party archives.
|
|
181
|
+
|
|
182
|
+
Copyright [yyyy] [name of copyright owner]
|
|
183
|
+
|
|
184
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
185
|
+
you may not use this file except in compliance with the License.
|
|
186
|
+
You may obtain a copy of the License at
|
|
187
|
+
|
|
188
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
189
|
+
|
|
190
|
+
Unless required by applicable law or agreed to in writing, software
|
|
191
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
192
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
193
|
+
See the License for the specific language governing permissions and
|
|
194
|
+
limitations under the License.
|
liveframe-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: liveframe
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Evidence-first measurement of real-time autoregressive diffusion video. Verifier CLI for LiveFrame claim ledgers and digest-bound artifacts.
|
|
5
|
+
Project-URL: Repository, https://github.com/kkjcodes/liveframe
|
|
6
|
+
Author-email: "Kumar K. Jha" <kumar.krishnanand@gmail.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: benchmarking,cuda,diffusion,mlx,reproducibility,video-generation
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# LiveFrame
|
|
25
|
+
|
|
26
|
+
**Real-time video generation, honestly measured.**
|
|
27
|
+
|
|
28
|
+
LiveFrame is an evidence-first measurement framework for real-time autoregressive
|
|
29
|
+
diffusion video, spanning NVIDIA CUDA and Apple MLX. It separates four claim layers —
|
|
30
|
+
numerical trajectory, intrinsic quality, same-seed identity, and complete-wall
|
|
31
|
+
performance — with pre-registered thresholds and digest-bound provenance.
|
|
32
|
+
|
|
33
|
+
Paper: *LiveFrame: Evidence-First Measurement of Real-Time Autoregressive Diffusion
|
|
34
|
+
Video Across CUDA and Apple MLX* (2026).
|
|
35
|
+
|
|
36
|
+
## This release (0.1.0)
|
|
37
|
+
|
|
38
|
+
This first release ships the **evidence verifier** for LiveFrame claim ledgers:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install liveframe
|
|
42
|
+
|
|
43
|
+
# re-hash every unique digest-bound artifact referenced by a ledger (fail-closed)
|
|
44
|
+
liveframe verify path/to/liveframe-publication-claims.v1.json --artifacts-root path/to/repo
|
|
45
|
+
|
|
46
|
+
# independently recompute headline arithmetic from values recorded in the ledger
|
|
47
|
+
liveframe recompute path/to/liveframe-publication-claims.v1.json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`verify` requires the separately distributed evidence artifacts referenced by the
|
|
51
|
+
ledger; model weights and evidence files are not bundled in this Python package.
|
|
52
|
+
It rejects missing files, digest mismatches, unsupported schemas, conflicting
|
|
53
|
+
references, and artifact paths outside the selected root.
|
|
54
|
+
|
|
55
|
+
The streaming engine APIs (`stream`, `clip`, `benchmark`) are planned for later
|
|
56
|
+
releases. See the repository for the full evidence bundle, claim protocol, and
|
|
57
|
+
reports.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
Apache-2.0
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# LiveFrame
|
|
2
|
+
|
|
3
|
+
**Real-time video generation, honestly measured.**
|
|
4
|
+
|
|
5
|
+
LiveFrame is an evidence-first measurement framework for real-time autoregressive
|
|
6
|
+
diffusion video, spanning NVIDIA CUDA and Apple MLX. It separates four claim layers —
|
|
7
|
+
numerical trajectory, intrinsic quality, same-seed identity, and complete-wall
|
|
8
|
+
performance — with pre-registered thresholds and digest-bound provenance.
|
|
9
|
+
|
|
10
|
+
Paper: *LiveFrame: Evidence-First Measurement of Real-Time Autoregressive Diffusion
|
|
11
|
+
Video Across CUDA and Apple MLX* (2026).
|
|
12
|
+
|
|
13
|
+
## This release (0.1.0)
|
|
14
|
+
|
|
15
|
+
This first release ships the **evidence verifier** for LiveFrame claim ledgers:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install liveframe
|
|
19
|
+
|
|
20
|
+
# re-hash every unique digest-bound artifact referenced by a ledger (fail-closed)
|
|
21
|
+
liveframe verify path/to/liveframe-publication-claims.v1.json --artifacts-root path/to/repo
|
|
22
|
+
|
|
23
|
+
# independently recompute headline arithmetic from values recorded in the ledger
|
|
24
|
+
liveframe recompute path/to/liveframe-publication-claims.v1.json
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`verify` requires the separately distributed evidence artifacts referenced by the
|
|
28
|
+
ledger; model weights and evidence files are not bundled in this Python package.
|
|
29
|
+
It rejects missing files, digest mismatches, unsupported schemas, conflicting
|
|
30
|
+
references, and artifact paths outside the selected root.
|
|
31
|
+
|
|
32
|
+
The streaming engine APIs (`stream`, `clip`, `benchmark`) are planned for later
|
|
33
|
+
releases. See the repository for the full evidence bundle, claim protocol, and
|
|
34
|
+
reports.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
Apache-2.0
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "liveframe"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Evidence-first measurement of real-time autoregressive diffusion video. Verifier CLI for LiveFrame claim ledgers and digest-bound artifacts."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE"]
|
|
12
|
+
authors = [{ name = "Kumar K. Jha", email = "kumar.krishnanand@gmail.com" }]
|
|
13
|
+
requires-python = ">=3.10"
|
|
14
|
+
keywords = ["diffusion", "video-generation", "benchmarking", "reproducibility", "mlx", "cuda"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"License :: OSI Approved :: Apache Software License",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Repository = "https://github.com/kkjcodes/liveframe"
|
|
31
|
+
|
|
32
|
+
[project.scripts]
|
|
33
|
+
liveframe = "liveframe.cli:main"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.sdist]
|
|
36
|
+
ignore-vcs = true
|
|
37
|
+
only-include = ["src", "tests"]
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.wheel]
|
|
40
|
+
packages = ["src/liveframe"]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""LiveFrame: evidence-first measurement of real-time autoregressive diffusion video.
|
|
2
|
+
|
|
3
|
+
Real-time video generation, honestly measured.
|
|
4
|
+
|
|
5
|
+
This initial release ships the evidence verifier for LiveFrame claim ledgers
|
|
6
|
+
(schema ``liveframe.publication-claims.v1``): it re-hashes referenced artifacts,
|
|
7
|
+
checks digest bindings, and recomputes headline arithmetic from ledger values.
|
|
8
|
+
The streaming engine APIs (``stream``, ``clip``, ``benchmark``) land in later releases.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"""LiveFrame evidence verifier CLI.
|
|
2
|
+
|
|
3
|
+
Usage:
|
|
4
|
+
liveframe verify <claims-ledger.json> [--artifacts-root DIR]
|
|
5
|
+
liveframe recompute <claims-ledger.json>
|
|
6
|
+
liveframe version
|
|
7
|
+
|
|
8
|
+
``verify`` re-hashes every artifact referenced by the ledger and fails closed on
|
|
9
|
+
any digest mismatch or missing file. ``recompute`` independently recalculates the
|
|
10
|
+
headline arithmetic (speedup, reduction fractions, target gap) from the values
|
|
11
|
+
recorded in the ledger and reports any inconsistency.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import argparse
|
|
17
|
+
import hashlib
|
|
18
|
+
import json
|
|
19
|
+
import math
|
|
20
|
+
import re
|
|
21
|
+
import sys
|
|
22
|
+
from collections.abc import Mapping
|
|
23
|
+
from pathlib import Path
|
|
24
|
+
from typing import Any
|
|
25
|
+
|
|
26
|
+
LEDGER_SCHEMA = "liveframe.publication-claims.v1"
|
|
27
|
+
SHA256_PATTERN = re.compile(r"^sha256:[0-9a-f]{64}$")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _sha256(path: Path) -> str:
|
|
31
|
+
h = hashlib.sha256()
|
|
32
|
+
with path.open("rb") as f:
|
|
33
|
+
for chunk in iter(lambda: f.read(1024 * 1024), b""):
|
|
34
|
+
h.update(chunk)
|
|
35
|
+
return "sha256:" + h.hexdigest()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _load_ledger(path: Path) -> dict[str, Any]:
|
|
39
|
+
ledger = json.loads(path.read_text(encoding="utf-8"))
|
|
40
|
+
if not isinstance(ledger, dict):
|
|
41
|
+
raise ValueError("claims ledger must be a JSON object")
|
|
42
|
+
if ledger.get("schema") != LEDGER_SCHEMA:
|
|
43
|
+
raise ValueError(
|
|
44
|
+
f"unsupported claims ledger schema: {ledger.get('schema', '<missing>')}"
|
|
45
|
+
)
|
|
46
|
+
return ledger
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _iter_artifact_refs(node: object, refs: dict[str, str]) -> dict[str, str]:
|
|
50
|
+
if isinstance(node, dict):
|
|
51
|
+
artifact = node.get("artifact")
|
|
52
|
+
digest = node.get("sha256")
|
|
53
|
+
if artifact is not None or digest is not None:
|
|
54
|
+
if not isinstance(artifact, str) or not isinstance(digest, str):
|
|
55
|
+
raise ValueError(
|
|
56
|
+
"artifact references require string artifact and sha256 fields"
|
|
57
|
+
)
|
|
58
|
+
if not SHA256_PATTERN.fullmatch(digest):
|
|
59
|
+
raise ValueError(f"invalid SHA-256 digest for artifact: {artifact}")
|
|
60
|
+
previous = refs.get(artifact)
|
|
61
|
+
if previous is not None and previous != digest:
|
|
62
|
+
raise ValueError(f"conflicting digests for artifact: {artifact}")
|
|
63
|
+
refs[artifact] = digest
|
|
64
|
+
for value in node.values():
|
|
65
|
+
_iter_artifact_refs(value, refs)
|
|
66
|
+
elif isinstance(node, list):
|
|
67
|
+
for value in node:
|
|
68
|
+
_iter_artifact_refs(value, refs)
|
|
69
|
+
return refs
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def cmd_verify(args: argparse.Namespace) -> int:
|
|
73
|
+
ledger_path = Path(args.ledger)
|
|
74
|
+
ledger = _load_ledger(ledger_path)
|
|
75
|
+
print(f"ledger: {ledger_path} schema: {ledger['schema']}")
|
|
76
|
+
root = (
|
|
77
|
+
Path(args.artifacts_root) if args.artifacts_root else ledger_path.parent.parent
|
|
78
|
+
).resolve()
|
|
79
|
+
refs = _iter_artifact_refs(ledger, {})
|
|
80
|
+
if not refs:
|
|
81
|
+
print("FAIL: ledger references no digest-bound artifacts")
|
|
82
|
+
return 2
|
|
83
|
+
failures = 0
|
|
84
|
+
for rel, expected in sorted(refs.items()):
|
|
85
|
+
relative = Path(rel)
|
|
86
|
+
if relative.is_absolute() or ".." in relative.parts:
|
|
87
|
+
print(f" INVALID {rel} (artifact path must remain below root)")
|
|
88
|
+
failures += 1
|
|
89
|
+
continue
|
|
90
|
+
target = (root / relative).resolve()
|
|
91
|
+
if not target.is_relative_to(root):
|
|
92
|
+
print(f" INVALID {rel} (artifact path resolves outside root)")
|
|
93
|
+
failures += 1
|
|
94
|
+
continue
|
|
95
|
+
if not target.is_file():
|
|
96
|
+
print(f" MISSING {rel}")
|
|
97
|
+
failures += 1
|
|
98
|
+
continue
|
|
99
|
+
actual = _sha256(target)
|
|
100
|
+
status = "ok" if actual == expected else "DIGEST MISMATCH"
|
|
101
|
+
if actual != expected:
|
|
102
|
+
failures += 1
|
|
103
|
+
print(f" {status} {rel}\n expected {expected}\n actual {actual}")
|
|
104
|
+
else:
|
|
105
|
+
print(f" ok {rel}")
|
|
106
|
+
if failures:
|
|
107
|
+
print(
|
|
108
|
+
f"FAIL: {failures}/{len(refs)} artifact reference(s) "
|
|
109
|
+
"did not verify (fail-closed)"
|
|
110
|
+
)
|
|
111
|
+
return 1
|
|
112
|
+
print(f"PASS: all {len(refs)} unique digest-bound artifacts verified")
|
|
113
|
+
return 0
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _number(container: Mapping[str, Any], name: str, context: str) -> float:
|
|
117
|
+
value = container.get(name)
|
|
118
|
+
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
|
119
|
+
raise ValueError(f"{context}.{name} must be numeric")
|
|
120
|
+
result = float(value)
|
|
121
|
+
if not math.isfinite(result):
|
|
122
|
+
raise ValueError(f"{context}.{name} must be finite")
|
|
123
|
+
return result
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def cmd_recompute(args: argparse.Namespace) -> int:
|
|
127
|
+
ledger = _load_ledger(Path(args.ledger))
|
|
128
|
+
problems = 0
|
|
129
|
+
checks = 0
|
|
130
|
+
engineering_speedups = ledger.get("engineering_speedups")
|
|
131
|
+
negative_results = ledger.get("negative_results")
|
|
132
|
+
if not isinstance(engineering_speedups, list):
|
|
133
|
+
raise ValueError("engineering_speedups must be an array")
|
|
134
|
+
if not isinstance(negative_results, list):
|
|
135
|
+
raise ValueError("negative_results must be an array")
|
|
136
|
+
for claim in engineering_speedups:
|
|
137
|
+
if not isinstance(claim, dict):
|
|
138
|
+
raise ValueError("each engineering speedup must be an object")
|
|
139
|
+
base, cand = claim.get("baseline", {}), claim.get("candidate", {})
|
|
140
|
+
if not isinstance(base, dict) or not isinstance(cand, dict):
|
|
141
|
+
raise ValueError("engineering speedup baseline and candidate must be objects")
|
|
142
|
+
claim_id = str(claim.get("id", "<missing>"))
|
|
143
|
+
bw = _number(base, "wall_seconds", f"{claim_id}.baseline")
|
|
144
|
+
cw = _number(cand, "wall_seconds", f"{claim_id}.candidate")
|
|
145
|
+
if bw <= 0 or cw <= 0:
|
|
146
|
+
raise ValueError(f"{claim_id} wall times must be positive")
|
|
147
|
+
speedup = bw / cw
|
|
148
|
+
reduction = (bw - cw) / bw
|
|
149
|
+
bv = _number(base, "vae_seconds", f"{claim_id}.baseline")
|
|
150
|
+
cv = _number(cand, "vae_seconds", f"{claim_id}.candidate")
|
|
151
|
+
if bv <= 0 or cv < 0:
|
|
152
|
+
raise ValueError(f"{claim_id} VAE times must be non-negative with positive baseline")
|
|
153
|
+
vae_reduction = (bv - cv) / bv
|
|
154
|
+
for name, computed in (
|
|
155
|
+
("wall_speedup", speedup),
|
|
156
|
+
("wall_reduction_fraction", reduction),
|
|
157
|
+
("vae_reduction_fraction", vae_reduction),
|
|
158
|
+
):
|
|
159
|
+
recorded = _number(claim, name, claim_id)
|
|
160
|
+
ok = abs(recorded - computed) < 1e-9
|
|
161
|
+
checks += 1
|
|
162
|
+
problems += 0 if ok else 1
|
|
163
|
+
print(
|
|
164
|
+
f" {claim_id}: {name} recorded={recorded:.9f} "
|
|
165
|
+
f"recomputed={computed:.9f} {'ok' if ok else 'MISMATCH'}"
|
|
166
|
+
)
|
|
167
|
+
for neg in negative_results:
|
|
168
|
+
if not isinstance(neg, dict):
|
|
169
|
+
raise ValueError("each negative result must be an object")
|
|
170
|
+
ev = neg.get("evidence", {})
|
|
171
|
+
if not isinstance(ev, dict) or not any(
|
|
172
|
+
name in ev
|
|
173
|
+
for name in ("generated_fps", "target_fps", "target_gap_factor")
|
|
174
|
+
):
|
|
175
|
+
continue
|
|
176
|
+
claim_id = str(neg.get("id", "<missing>"))
|
|
177
|
+
fps = _number(ev, "generated_fps", f"{claim_id}.evidence")
|
|
178
|
+
target = _number(ev, "target_fps", f"{claim_id}.evidence")
|
|
179
|
+
gap = _number(ev, "target_gap_factor", f"{claim_id}.evidence")
|
|
180
|
+
if fps <= 0 or target <= 0:
|
|
181
|
+
raise ValueError(f"{claim_id} FPS values must be positive")
|
|
182
|
+
computed = target / fps
|
|
183
|
+
ok = abs(gap - computed) < 1e-9
|
|
184
|
+
checks += 1
|
|
185
|
+
problems += 0 if ok else 1
|
|
186
|
+
print(
|
|
187
|
+
f" {claim_id}: target_gap_factor recorded={gap:.9f} "
|
|
188
|
+
f"recomputed={computed:.9f} {'ok' if ok else 'MISMATCH'}"
|
|
189
|
+
)
|
|
190
|
+
if checks == 0:
|
|
191
|
+
print("FAIL: ledger contains no supported arithmetic claims")
|
|
192
|
+
return 2
|
|
193
|
+
if problems:
|
|
194
|
+
print(f"FAIL: {problems} arithmetic inconsistency(ies)")
|
|
195
|
+
return 1
|
|
196
|
+
print("PASS: ledger arithmetic reproduces")
|
|
197
|
+
return 0
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def main(argv: list[str] | None = None) -> int:
|
|
201
|
+
parser = argparse.ArgumentParser(prog="liveframe", description=__doc__)
|
|
202
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
203
|
+
p_verify = sub.add_parser(
|
|
204
|
+
"verify", help="verify digest-bound artifact references in a claims ledger"
|
|
205
|
+
)
|
|
206
|
+
p_verify.add_argument("ledger")
|
|
207
|
+
p_verify.add_argument(
|
|
208
|
+
"--artifacts-root",
|
|
209
|
+
default=None,
|
|
210
|
+
help="root directory artifact paths are relative to (default: ledger grandparent)",
|
|
211
|
+
)
|
|
212
|
+
p_verify.set_defaults(func=cmd_verify)
|
|
213
|
+
p_re = sub.add_parser("recompute", help="recompute headline arithmetic from ledger values")
|
|
214
|
+
p_re.add_argument("ledger")
|
|
215
|
+
p_re.set_defaults(func=cmd_recompute)
|
|
216
|
+
p_v = sub.add_parser("version", help="print version")
|
|
217
|
+
p_v.set_defaults(func=lambda a: (print(__import__("liveframe").__version__), 0)[1])
|
|
218
|
+
args = parser.parse_args(argv)
|
|
219
|
+
try:
|
|
220
|
+
return args.func(args)
|
|
221
|
+
except (OSError, UnicodeError, json.JSONDecodeError, ValueError) as error:
|
|
222
|
+
print(f"FAIL: {error}", file=sys.stderr)
|
|
223
|
+
return 2
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
if __name__ == "__main__":
|
|
227
|
+
sys.exit(main())
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import json
|
|
5
|
+
import tempfile
|
|
6
|
+
import unittest
|
|
7
|
+
from contextlib import redirect_stderr, redirect_stdout
|
|
8
|
+
from io import StringIO
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
from liveframe.cli import main
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class CliTests(unittest.TestCase):
|
|
15
|
+
def setUp(self) -> None:
|
|
16
|
+
self.temporary_directory = tempfile.TemporaryDirectory()
|
|
17
|
+
self.root = Path(self.temporary_directory.name)
|
|
18
|
+
artifact = self.root / "artifacts" / "sample.json"
|
|
19
|
+
artifact.parent.mkdir()
|
|
20
|
+
artifact.write_text('{"passed": true}\n', encoding="utf-8")
|
|
21
|
+
digest = "sha256:" + hashlib.sha256(artifact.read_bytes()).hexdigest()
|
|
22
|
+
self.ledger = self.root / "artifacts" / "claims.json"
|
|
23
|
+
self.payload = {
|
|
24
|
+
"schema": "liveframe.publication-claims.v1",
|
|
25
|
+
"engineering_speedups": [
|
|
26
|
+
{
|
|
27
|
+
"id": "speedup",
|
|
28
|
+
"baseline": {
|
|
29
|
+
"artifact": "artifacts/sample.json",
|
|
30
|
+
"sha256": digest,
|
|
31
|
+
"wall_seconds": 10.0,
|
|
32
|
+
"vae_seconds": 8.0,
|
|
33
|
+
},
|
|
34
|
+
"candidate": {
|
|
35
|
+
"artifact": "artifacts/sample.json",
|
|
36
|
+
"sha256": digest,
|
|
37
|
+
"wall_seconds": 8.0,
|
|
38
|
+
"vae_seconds": 6.0,
|
|
39
|
+
},
|
|
40
|
+
"wall_speedup": 1.25,
|
|
41
|
+
"wall_reduction_fraction": 0.2,
|
|
42
|
+
"vae_reduction_fraction": 0.25,
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"negative_results": [
|
|
46
|
+
{
|
|
47
|
+
"id": "target-gap",
|
|
48
|
+
"evidence": {
|
|
49
|
+
"generated_fps": 2.0,
|
|
50
|
+
"target_fps": 16.0,
|
|
51
|
+
"target_gap_factor": 8.0,
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
}
|
|
56
|
+
self._write_ledger()
|
|
57
|
+
|
|
58
|
+
def tearDown(self) -> None:
|
|
59
|
+
self.temporary_directory.cleanup()
|
|
60
|
+
|
|
61
|
+
def _write_ledger(self) -> None:
|
|
62
|
+
self.ledger.write_text(json.dumps(self.payload), encoding="utf-8")
|
|
63
|
+
|
|
64
|
+
def _run(self, *arguments: str) -> tuple[int, str]:
|
|
65
|
+
output = StringIO()
|
|
66
|
+
with redirect_stdout(output), redirect_stderr(output):
|
|
67
|
+
result = main(list(arguments))
|
|
68
|
+
return result, output.getvalue()
|
|
69
|
+
|
|
70
|
+
def test_verify_deduplicates_repeated_artifact(self) -> None:
|
|
71
|
+
result, output = self._run(
|
|
72
|
+
"verify", str(self.ledger), "--artifacts-root", str(self.root)
|
|
73
|
+
)
|
|
74
|
+
self.assertEqual(result, 0)
|
|
75
|
+
self.assertIn("all 1 unique digest-bound artifacts verified", output)
|
|
76
|
+
|
|
77
|
+
def test_verify_fails_on_digest_mismatch(self) -> None:
|
|
78
|
+
self.payload["engineering_speedups"][0]["baseline"]["sha256"] = (
|
|
79
|
+
"sha256:" + "0" * 64
|
|
80
|
+
)
|
|
81
|
+
self.payload["engineering_speedups"][0]["candidate"]["sha256"] = (
|
|
82
|
+
"sha256:" + "0" * 64
|
|
83
|
+
)
|
|
84
|
+
self._write_ledger()
|
|
85
|
+
result, output = self._run(
|
|
86
|
+
"verify", str(self.ledger), "--artifacts-root", str(self.root)
|
|
87
|
+
)
|
|
88
|
+
self.assertEqual(result, 1)
|
|
89
|
+
self.assertIn("DIGEST MISMATCH", output)
|
|
90
|
+
|
|
91
|
+
def test_verify_rejects_path_outside_root(self) -> None:
|
|
92
|
+
claim = self.payload["engineering_speedups"][0]
|
|
93
|
+
claim["baseline"]["artifact"] = "../sample.json"
|
|
94
|
+
claim["candidate"]["artifact"] = "../sample.json"
|
|
95
|
+
self._write_ledger()
|
|
96
|
+
result, output = self._run(
|
|
97
|
+
"verify", str(self.ledger), "--artifacts-root", str(self.root)
|
|
98
|
+
)
|
|
99
|
+
self.assertEqual(result, 1)
|
|
100
|
+
self.assertIn("artifact path must remain below root", output)
|
|
101
|
+
|
|
102
|
+
def test_verify_rejects_incomplete_artifact_reference(self) -> None:
|
|
103
|
+
del self.payload["engineering_speedups"][0]["baseline"]["sha256"]
|
|
104
|
+
self._write_ledger()
|
|
105
|
+
result, output = self._run("verify", str(self.ledger))
|
|
106
|
+
self.assertEqual(result, 2)
|
|
107
|
+
self.assertIn("artifact references require", output)
|
|
108
|
+
|
|
109
|
+
def test_recompute_checks_all_supported_arithmetic(self) -> None:
|
|
110
|
+
result, output = self._run("recompute", str(self.ledger))
|
|
111
|
+
self.assertEqual(result, 0)
|
|
112
|
+
self.assertEqual(output.count(" ok"), 4)
|
|
113
|
+
self.assertIn("vae_reduction_fraction", output)
|
|
114
|
+
|
|
115
|
+
def test_recompute_rejects_empty_ledger(self) -> None:
|
|
116
|
+
self.payload["engineering_speedups"] = []
|
|
117
|
+
self.payload["negative_results"] = []
|
|
118
|
+
self._write_ledger()
|
|
119
|
+
result, output = self._run("recompute", str(self.ledger))
|
|
120
|
+
self.assertEqual(result, 2)
|
|
121
|
+
self.assertIn("no supported arithmetic claims", output)
|
|
122
|
+
|
|
123
|
+
def test_rejects_unsupported_schema_without_traceback(self) -> None:
|
|
124
|
+
self.payload["schema"] = "unknown"
|
|
125
|
+
self._write_ledger()
|
|
126
|
+
result, output = self._run("verify", str(self.ledger))
|
|
127
|
+
self.assertEqual(result, 2)
|
|
128
|
+
self.assertIn("unsupported claims ledger schema", output)
|
|
129
|
+
self.assertNotIn("Traceback", output)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
if __name__ == "__main__":
|
|
133
|
+
unittest.main()
|