machinechecked 0.1.14__tar.gz → 0.1.16__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.
- {machinechecked-0.1.14 → machinechecked-0.1.16}/PKG-INFO +1 -1
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/PKG-INFO +1 -1
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/SOURCES.txt +4 -2
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/audit.py +8 -1
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/cache.py +20 -8
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/cli.py +1 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/config.py +8 -1
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/ProofLensProbe.lean +23 -9
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/export.py +6 -2
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/formalization.py +2 -1
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/manifest.py +2 -2
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/paper.py +52 -3
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/pipeline.py +17 -7
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/published.py +42 -0
- machinechecked-0.1.16/engine/python/prooflens/repin.py +473 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/simple.py +56 -1
- machinechecked-0.1.16/engine/python/prooflens/versions.py +171 -0
- machinechecked-0.1.14/engine/python/prooflens/web/assets/index-GfZV3aEH.css → machinechecked-0.1.16/engine/python/prooflens/web/assets/index-BNMmM1YT.css +1 -1
- machinechecked-0.1.16/engine/python/prooflens/web/assets/index-CRqix-cK.js +278 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/index.html +2 -2
- {machinechecked-0.1.14 → machinechecked-0.1.16}/pyproject.toml +1 -1
- machinechecked-0.1.14/engine/python/prooflens/web/assets/index-YAI0NIYT.js +0 -278
- {machinechecked-0.1.14 → machinechecked-0.1.16}/LICENSE +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/README.md +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/dependency_links.txt +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/entry_points.txt +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/requires.txt +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/top_level.txt +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/__init__.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/__main__.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/assess.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/bundle.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/prooflens.sty +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/schema/evidence.schema.json +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/schema/inventory.schema.json +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/schema/manifest-claim.schema.json +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/schema/manifest-index.schema.json +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/statuses.json +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/deps.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/evidence.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/pdfclaims.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/probe.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/promote.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/replay.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/review_cli.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/review_queue.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/reviews.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/schemas.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/server.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/source_regions.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/sources.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/status.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/symbols.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/tex.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/util.py +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/web/theme.css +0 -0
- {machinechecked-0.1.14 → machinechecked-0.1.16}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: machinechecked
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Read a mathematical paper beside its Lean formalisation, and see claim by claim what Lean establishes.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://machinechecked.org
|
{machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: machinechecked
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.16
|
|
4
4
|
Summary: Read a mathematical paper beside its Lean formalisation, and see claim by claim what Lean establishes.
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Project-URL: Homepage, https://machinechecked.org
|
{machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/machinechecked.egg-info/SOURCES.txt
RENAMED
|
@@ -26,6 +26,7 @@ engine/python/prooflens/pipeline.py
|
|
|
26
26
|
engine/python/prooflens/probe.py
|
|
27
27
|
engine/python/prooflens/promote.py
|
|
28
28
|
engine/python/prooflens/published.py
|
|
29
|
+
engine/python/prooflens/repin.py
|
|
29
30
|
engine/python/prooflens/replay.py
|
|
30
31
|
engine/python/prooflens/review_cli.py
|
|
31
32
|
engine/python/prooflens/review_queue.py
|
|
@@ -39,6 +40,7 @@ engine/python/prooflens/status.py
|
|
|
39
40
|
engine/python/prooflens/symbols.py
|
|
40
41
|
engine/python/prooflens/tex.py
|
|
41
42
|
engine/python/prooflens/util.py
|
|
43
|
+
engine/python/prooflens/versions.py
|
|
42
44
|
engine/python/prooflens/data/ProofLensProbe.lean
|
|
43
45
|
engine/python/prooflens/data/prooflens.sty
|
|
44
46
|
engine/python/prooflens/data/statuses.json
|
|
@@ -68,6 +70,6 @@ engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2
|
|
|
68
70
|
engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2
|
|
69
71
|
engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2
|
|
70
72
|
engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg
|
|
71
|
-
engine/python/prooflens/web/assets/index-
|
|
72
|
-
engine/python/prooflens/web/assets/index-
|
|
73
|
+
engine/python/prooflens/web/assets/index-BNMmM1YT.css
|
|
74
|
+
engine/python/prooflens/web/assets/index-CRqix-cK.js
|
|
73
75
|
engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""The audit descriptor: `audit.json` at the root of a published reader.
|
|
2
2
|
|
|
3
3
|
It says, in a few fields, what the audit is about and where its data is: the paper (and its
|
|
4
|
-
arXiv identifier
|
|
4
|
+
arXiv identifier when it has one), the version of the paper it pins (`paper_version`: published,
|
|
5
|
+
such as arXiv v1, or an unpublished manuscript at a commit), the Lean repository and commit, who published
|
|
5
6
|
the audit, where reports go, and the path of the reader's data. A site that indexes audits reads
|
|
6
7
|
this file and then the data it points to; it never runs anything an audit contains.
|
|
7
8
|
|
|
@@ -77,6 +78,12 @@ def descriptor(index: dict, lean_root: Path | None, author: str | None = None,
|
|
|
77
78
|
entry.update(published_record(p["published"]))
|
|
78
79
|
if p.get("published_note"):
|
|
79
80
|
entry["note"] = p["published_note"]
|
|
81
|
+
# The version this audit pins (engine/python/prooflens/versions.py). An unpublished
|
|
82
|
+
# manuscript carries no published version number, even when `published` names the paper.
|
|
83
|
+
ver = p.get("paper_version")
|
|
84
|
+
entry["paper_version"] = ver
|
|
85
|
+
if ver and ver.get("kind") == "manuscript":
|
|
86
|
+
entry["version"] = None
|
|
80
87
|
papers.append(entry)
|
|
81
88
|
project = index.get("project") or {}
|
|
82
89
|
return {
|
|
@@ -220,13 +220,18 @@ def check_space(project: Path, tmp: Path, man: dict) -> None:
|
|
|
220
220
|
"revision, or old build output) and restore again; nothing was changed")
|
|
221
221
|
|
|
222
222
|
|
|
223
|
-
def _unpack(arc: Path, project: Path) -> None:
|
|
223
|
+
def _unpack(arc: Path, project: Path, older: bool = False) -> None:
|
|
224
224
|
"""Unpack an archive written by `_pack` into the project and its path dependencies, with the
|
|
225
225
|
tar `data` filter (no absolute paths, no `..`, no links out of the destination). Everything
|
|
226
226
|
is unpacked into a staging folder first and moved into place only once the whole archive
|
|
227
|
-
has been read, so a failure (a full disk, a corrupt archive) leaves the build as it was.
|
|
227
|
+
has been read, so a failure (a full disk, a corrupt archive) leaves the build as it was.
|
|
228
|
+
|
|
229
|
+
An archive in the older layout (`older`) holds paths from the checkout's parent, under the
|
|
230
|
+
folder names of the checkout it was made in; each top folder is mapped onto the project or a
|
|
231
|
+
path dependency whose folder has that name in any case, and any other path is refused."""
|
|
228
232
|
import tarfile
|
|
229
233
|
deps = {d.name: d for d in path_deps(project)}
|
|
234
|
+
folded = {d.name.lower(): d for d in deps.values()}
|
|
230
235
|
stage = Path(tempfile.mkdtemp(prefix=".lean-cache-restore-", dir=project))
|
|
231
236
|
try:
|
|
232
237
|
bases: dict[str, Path] = {}
|
|
@@ -234,7 +239,17 @@ def _unpack(arc: Path, project: Path) -> None:
|
|
|
234
239
|
with tarfile.open(fileobj=z.stdout, mode="r|") as tf:
|
|
235
240
|
for m in tf:
|
|
236
241
|
head, _, rest = m.name.partition("/")
|
|
237
|
-
if
|
|
242
|
+
if older and not rest.strip("/") and m.isdir():
|
|
243
|
+
continue # the top folder itself
|
|
244
|
+
if older and rest and head.lower() == project.name.lower():
|
|
245
|
+
key, base, m.name = "project", project, rest
|
|
246
|
+
elif older and rest and head.lower() in folded:
|
|
247
|
+
base = folded[head.lower()]
|
|
248
|
+
key, m.name = f"path-{base.name}", rest
|
|
249
|
+
elif older:
|
|
250
|
+
raise CacheError(f"the archive's path {m.name} is not in this project or a "
|
|
251
|
+
"path dependency of it; build from source")
|
|
252
|
+
elif head == "project" and rest:
|
|
238
253
|
key, base, m.name = "project", project, rest
|
|
239
254
|
elif head == "path" and rest.partition("/")[0] in deps:
|
|
240
255
|
name, _, m.name = rest.partition("/")
|
|
@@ -428,7 +443,7 @@ def restore(project: Path, repo: str | None = None, local: Path | None = None,
|
|
|
428
443
|
src.fetch(name, tmp / name)
|
|
429
444
|
man = json.loads((tmp / name).read_text())
|
|
430
445
|
if not man.get("layout") and not name.startswith(_prefix(project.name)):
|
|
431
|
-
continue # an archive in the older layout
|
|
446
|
+
continue # an archive in the older layout is named after the checkout's folder
|
|
432
447
|
wanted = [p["name"] for p in man["parts"]] if man.get("parts") else [f"{stem}.tar.zst"]
|
|
433
448
|
if any(w not in src.assets for w in wanted):
|
|
434
449
|
continue
|
|
@@ -481,10 +496,7 @@ def restore(project: Path, repo: str | None = None, local: Path | None = None,
|
|
|
481
496
|
if got != man["sha256"]:
|
|
482
497
|
raise CacheError(f"sha256 {got} is not the manifest's {man['sha256']}; "
|
|
483
498
|
"build from source")
|
|
484
|
-
|
|
485
|
-
_unpack(arc, project)
|
|
486
|
-
else:
|
|
487
|
-
_sh(["tar", "-C", str(project.parent), "-I", "zstd -T0", "-xf", str(arc)])
|
|
499
|
+
_unpack(arc, project, older=man.get("layout") != 2)
|
|
488
500
|
log(f"restored {stem} ("
|
|
489
501
|
+ ("the same Lean inputs" if key[0] == 0 else f"{dist} commits behind HEAD")
|
|
490
502
|
+ f", sha256 {got[:16]}…) "
|
|
@@ -352,6 +352,7 @@ def _check_json(a):
|
|
|
352
352
|
"status": c["status"], "status_code": c["status_code"], "class": c["class"],
|
|
353
353
|
"links": [{"name": l["name"], "status": l["status"], "status_code": l["status_code"], "class": l["class"],
|
|
354
354
|
"source": l.get("source")} for l in c["links"]],
|
|
355
|
+
"correspondence": c.get("correspondence"),
|
|
355
356
|
"suggestions": [{"name": x["name"], "why": x.get("why")}
|
|
356
357
|
for x in c.get("suggestions", [])]}
|
|
357
358
|
for c in body["claims"]]
|
|
@@ -38,6 +38,10 @@ class Paper:
|
|
|
38
38
|
# a DOI or a URL), and how the revision differs from it. Descriptive only: no status uses it.
|
|
39
39
|
published: str | None = None
|
|
40
40
|
published_note: str | None = None
|
|
41
|
+
# The version of the paper this audit pins: "published" (the version `published` names) or
|
|
42
|
+
# "manuscript" (the unpublished source at its pinned revision, `source.rev`). When absent, a
|
|
43
|
+
# paper with `published` (or an arXiv source) pins that published version (docs/ASSURANCE.md).
|
|
44
|
+
version: str | None = None
|
|
41
45
|
# A paper whose source is a PDF: the PDF's SHA-256, pinned by the configuration. The release
|
|
42
46
|
# gate accepts a PDF as source evidence only when it is pinned and matches (EVIDENCE_POLICY).
|
|
43
47
|
pdf_sha256: str | None = None
|
|
@@ -118,11 +122,14 @@ def load(path: str | Path) -> Config:
|
|
|
118
122
|
src = _req(p, "source", "paper")
|
|
119
123
|
if not any(k in src for k in ("path", "git", "arxiv")):
|
|
120
124
|
raise ConfigError(f"paper {p.get('id')}: source needs one of path, git, arxiv")
|
|
125
|
+
if p.get("version") not in (None, "published", "manuscript"):
|
|
126
|
+
raise ConfigError(f"paper {p.get('id')}: version must be \"published\" or "
|
|
127
|
+
f"\"manuscript\", not {p.get('version')!r}")
|
|
121
128
|
papers.append(Paper(
|
|
122
129
|
id=_req(p, "id", "paper"), title=p.get("title", p["id"]), source=src,
|
|
123
130
|
root=p.get("root"), pdf=p.get("pdf"), pdf_sha256=p.get("pdf_sha256"), commit=src.get("rev"), envs=p.get("envs"),
|
|
124
131
|
publish=Publish(**p.get("publish", {})), published=p.get("published"),
|
|
125
|
-
published_note=p.get("note")))
|
|
132
|
+
published_note=p.get("note"), version=p.get("version")))
|
|
126
133
|
return Config(
|
|
127
134
|
path=path,
|
|
128
135
|
name=_req(proj, "name", "project"),
|
{machinechecked-0.1.14 → machinechecked-0.1.16}/engine/python/prooflens/data/ProofLensProbe.lean
RENAMED
|
@@ -36,8 +36,16 @@ structure Query where
|
|
|
36
36
|
accept_prefix : String
|
|
37
37
|
allowed_axioms : Array String
|
|
38
38
|
requests : Array Request
|
|
39
|
+
/-- Each request's heartbeat budget, in thousands as `maxHeartbeats`; Lean's default if none. -/
|
|
40
|
+
max_heartbeats : Option Nat := none
|
|
39
41
|
deriving FromJson, Inhabited
|
|
40
42
|
|
|
43
|
+
/-- Runs `x` with a heartbeat budget of `n` thousand heartbeats when one is given. -/
|
|
44
|
+
def withBudget (n? : Option Nat) (x : MetaM α) : MetaM α :=
|
|
45
|
+
match n? with
|
|
46
|
+
| some n => withTheReader Core.Context (fun c => { c with maxHeartbeats := n * 1000 }) x
|
|
47
|
+
| none => x
|
|
48
|
+
|
|
41
49
|
/-! ## Environment helpers -/
|
|
42
50
|
|
|
43
51
|
def moduleOf (env : Environment) (n : Name) : Name :=
|
|
@@ -376,7 +384,8 @@ def emitClosure (h : IO.FS.Handle) (roots : Array Name) (root : Name) (used : Ar
|
|
|
376
384
|
unless inScope roots env n do continue
|
|
377
385
|
let some c := env.find? n | continue
|
|
378
386
|
members := members.push n.toString
|
|
379
|
-
|
|
387
|
+
-- Each member has its own heartbeat budget: a closure can hold thousands.
|
|
388
|
+
let (j, more) ← withCurrHeartbeats (declRecord roots n c)
|
|
380
389
|
unless (← seen.get).contains n do
|
|
381
390
|
seen.modify (·.insert n)
|
|
382
391
|
emit h j
|
|
@@ -479,7 +488,10 @@ def indexRecords (h : IO.FS.Handle) (roots : Array Name) : MetaM Unit := do
|
|
|
479
488
|
| .axiomInfo _ => some "axiom" | _ => none
|
|
480
489
|
let some k := kind | continue
|
|
481
490
|
if k == "def" && (← isInstance n) then continue
|
|
482
|
-
|
|
491
|
+
-- Each declaration printed has its own heartbeat budget: a project can hold tens of
|
|
492
|
+
-- thousands, more than one budget prints.
|
|
493
|
+
let ty ← withCurrHeartbeats do
|
|
494
|
+
try pure (toString (← ppExpr ci.type)) catch _ => pure "(not printable)"
|
|
483
495
|
let doc ← findDocString? env n
|
|
484
496
|
emit h (Json.mkObj [("record", "index"), ("name", n.toString), ("kind", k),
|
|
485
497
|
("module", mod.toString), ("range", ← rangeJson n),
|
|
@@ -624,8 +636,10 @@ open ProofLensProbe in
|
|
|
624
636
|
("githash", Lean.githash)])
|
|
625
637
|
layering h q
|
|
626
638
|
for r in q.requests do
|
|
627
|
-
-- Each request has its own heartbeat budget.
|
|
628
|
-
try
|
|
639
|
+
-- Each request has its own heartbeat budget. A request that fails, including by running
|
|
640
|
+
-- out of heartbeats (a runtime exception, which `try` does not catch), emits an error
|
|
641
|
+
-- record for itself and the probe goes on.
|
|
642
|
+
tryCatchRuntimeEx (withBudget q.max_heartbeats <| withCurrHeartbeats do
|
|
629
643
|
match r.kind with
|
|
630
644
|
| "spec" => specRecord h q roots seen r.name.toName
|
|
631
645
|
| "accept" | "refute" => proofRecord h q r.kind r.name.toName (r.spec.map (·.toName))
|
|
@@ -645,9 +659,9 @@ open ProofLensProbe in
|
|
|
645
659
|
else
|
|
646
660
|
emit h (Json.mkObj [("record", "defclosure"), ("name", r.name),
|
|
647
661
|
("errors", toJson #["missing"])])
|
|
648
|
-
| _ => pure ()
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
662
|
+
| _ => pure ())
|
|
663
|
+
(fun err => do
|
|
664
|
+
emit h (Json.mkObj [("record", if r.kind == "decl" then "defclosure" else r.kind),
|
|
665
|
+
("name", r.name), ("spec", match r.spec with | some x => Json.str x | none => Json.null),
|
|
666
|
+
("errors", toJson #[s!"probe-error: {← err.toMessageData.toString}"])]))
|
|
653
667
|
emit h (Json.mkObj [("record", "done")])
|
|
@@ -105,7 +105,10 @@ def public_claim(chunk: dict, pub) -> dict:
|
|
|
105
105
|
out["location"] = chunk.get("location") if pub.source_text else None
|
|
106
106
|
out["statement_tex"] = chunk.get("statement_tex") if pub.source_text else None
|
|
107
107
|
a = chunk.get("anchor")
|
|
108
|
-
|
|
108
|
+
# `head` (the baseline of the first line) is what the index's top is computed from, so the
|
|
109
|
+
# published claim must keep it for its location to agree with the index.
|
|
110
|
+
out["anchor"] = _pick(a, ["id", "env", "number", "label", "begin", "head", "end", "kind",
|
|
111
|
+
"source_sha256"] +
|
|
109
112
|
(["file", "line"] if pub.source_text else [])) if a else None
|
|
110
113
|
clauses = []
|
|
111
114
|
for cl in chunk["clauses"]:
|
|
@@ -279,7 +282,8 @@ def export(cfg: Config, out: Path, release: str | None = None,
|
|
|
279
282
|
for p in index["papers"]:
|
|
280
283
|
pub = pubs[p["id"]]
|
|
281
284
|
q = _pick(p, ["id", "title", "mode", "revision", "pdf_sha256", "page_size", "note",
|
|
282
|
-
"published", "published_note", "source_commit"
|
|
285
|
+
"published", "published_note", "source_commit",
|
|
286
|
+
"paper_version"])
|
|
283
287
|
q["root"] = p.get("root") if pub.source_text else None
|
|
284
288
|
q["pdf"] = p["pdf"] if pub.pdf else None
|
|
285
289
|
pidx["papers"].append(q)
|
|
@@ -64,9 +64,10 @@ def statements(fy: dict) -> list[dict]:
|
|
|
64
64
|
continue
|
|
65
65
|
rest = src[m.end():]
|
|
66
66
|
module = r.get("module") if isinstance(r.get("module"), str) else None
|
|
67
|
+
note = r.get("note").strip() if isinstance(r.get("note"), str) else ""
|
|
67
68
|
out.append({"source": src, "kind": m.group(1).lower(), "number": m.group(2),
|
|
68
69
|
"hint": _tokens(rest), "lean": names, "status": r.get("status"),
|
|
69
|
-
"module": module})
|
|
70
|
+
"module": module, "note": note})
|
|
70
71
|
return out
|
|
71
72
|
|
|
72
73
|
|
|
@@ -142,8 +142,8 @@ def build(evidence: dict, release: str, display: dict | None = None
|
|
|
142
142
|
"pdf": f"papers/{pid}.pdf" if prov.get("pdf_sha256") else None,
|
|
143
143
|
"pdf_sha256": prov.get("pdf_sha256"), "page_size": t.get("page_size"),
|
|
144
144
|
"note": prov.get("note", ""),
|
|
145
|
-
**{k: prov[k] for k in ("published", "published_note", "source_commit"
|
|
146
|
-
|
|
145
|
+
**{k: prov[k] for k in ("published", "published_note", "source_commit",
|
|
146
|
+
"paper_version") if prov.get(k)}})
|
|
147
147
|
|
|
148
148
|
store = decl_records(body, lean)
|
|
149
149
|
keys = {n: record_key(r) for n, r in store.items()}
|
|
@@ -102,15 +102,62 @@ def _state(links: list[dict], audit: dict | None = None, audited: bool = False)
|
|
|
102
102
|
return fields("link.not-in-audit" if audited else "link.no-audit")
|
|
103
103
|
|
|
104
104
|
|
|
105
|
+
HREF = re.compile(r"(?!//)(?![a-z][\w+.-]*:)[\w./~%-]*", re.I)
|
|
106
|
+
HTTPS = re.compile(r"https://[^\s\"'<>]+")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def page_versions(entries: list[dict], current: str) -> list[dict]:
|
|
110
|
+
"""The versions of a paper its page offers (one page per version, each with its own PDF,
|
|
111
|
+
claim numbering and audits), as the reader's version drop-down receives them. Each entry
|
|
112
|
+
gives `id` and `kind` as an audit's `paper_version` does (a manuscript also its `revision`),
|
|
113
|
+
`href` (the address of that version's page, on the same site), and optionally `pdf` and
|
|
114
|
+
`audits` (`url`, `author`, `repository`). The label is MachineChecked's for that version,
|
|
115
|
+
never one the entry supplies; `current` is the id of the version this page shows."""
|
|
116
|
+
from .published import AuditError, paper_version
|
|
117
|
+
out = []
|
|
118
|
+
for e in entries:
|
|
119
|
+
try:
|
|
120
|
+
rec = paper_version({k: e.get(k) for k in ("kind", "id", "revision")})
|
|
121
|
+
except AuditError as err:
|
|
122
|
+
raise ValueError(f"paper version {e.get('id')!r}: {err}") from None
|
|
123
|
+
href = e.get("href")
|
|
124
|
+
if not isinstance(href, str) or not href or not HREF.fullmatch(href):
|
|
125
|
+
raise ValueError(f"paper version {rec['id']}: href must be an address on this site")
|
|
126
|
+
pdf = e.get("pdf")
|
|
127
|
+
if pdf is not None and not (isinstance(pdf, str) and (HTTPS.fullmatch(pdf) or
|
|
128
|
+
HREF.fullmatch(pdf))):
|
|
129
|
+
raise ValueError(f"paper version {rec['id']}: pdf must be https or on this site")
|
|
130
|
+
audits = [{k: a.get(k) for k in ("url", "author", "repository") if a.get(k)}
|
|
131
|
+
for a in e.get("audits") or [] if HTTPS.fullmatch(str(a.get("url", "")))]
|
|
132
|
+
out.append({"id": rec["id"], "kind": rec["kind"], "label": rec["label"],
|
|
133
|
+
**({"revision": rec["revision"]} if rec.get("revision") else {}),
|
|
134
|
+
"href": href, "pdf": pdf, "audits": audits})
|
|
135
|
+
ids = [v["id"] for v in out]
|
|
136
|
+
if len(set(ids)) != len(ids) or ids.count(current) != 1:
|
|
137
|
+
raise ValueError(f"the versions must be distinct and include this page's ({current})")
|
|
138
|
+
return out
|
|
139
|
+
|
|
140
|
+
|
|
105
141
|
def write_paper_site(site: Path, paper: dict, claims: list[dict],
|
|
106
142
|
page_size: list | tuple | None, pdf_url: str | None,
|
|
107
|
-
web_dist: Path | None = None, audits: dict | None = None
|
|
143
|
+
web_dist: Path | None = None, audits: dict | None = None,
|
|
144
|
+
versions: list[dict] | None = None, version: str | None = None) -> dict:
|
|
108
145
|
"""Write the paper page's data under `site/data/` (and the reader, given its built
|
|
109
146
|
directory). `paper` is the paper's registry entry (its identifier, title, authors, links and
|
|
110
147
|
formalisations), which the reader's panel beside the paper shows; `claims` are from
|
|
111
|
-
`paper_claims`.
|
|
148
|
+
`paper_claims`. A paper with several versions has a page per version: `version` is the id of
|
|
149
|
+
this page's, `versions` every version's entry (`page_versions`), and every audit loaded for
|
|
150
|
+
this page must pin this version. Replaces whatever is at `site`."""
|
|
112
151
|
from .pipeline import write_preview
|
|
152
|
+
from .published import same_version
|
|
113
153
|
audits_loaded = audits or {}
|
|
154
|
+
offered = page_versions(versions, version) if versions else None
|
|
155
|
+
if offered:
|
|
156
|
+
for r, a in audits_loaded.items():
|
|
157
|
+
pv = a.get("paper_version") if a.get("state") == "loaded" else None
|
|
158
|
+
if a.get("state") == "loaded" and not (pv and same_version(pv["id"], version)):
|
|
159
|
+
raise ValueError(f"the audit of {r} does not pin {version}: load it with the "
|
|
160
|
+
"listing's version (load_published_audit)")
|
|
114
161
|
projects = [f["repository"] for f in paper.get("formalisations", [])]
|
|
115
162
|
audited = {r for r, a in audits_loaded.items() if a.get("state") == "loaded"} if audits is not None else {f["repository"] for f in paper.get("formalisations", []) if f.get("audits")}
|
|
116
163
|
index_claims, chunks = [], {}
|
|
@@ -167,10 +214,12 @@ def write_paper_site(site: Path, paper: dict, claims: list[dict],
|
|
|
167
214
|
editions = {a["paper"]["edition"]: {**a["paper"], "author": a.get("author"), "repository": r}
|
|
168
215
|
for r, a in audits_loaded.items() if a.get("paper", {}).get("edition")}
|
|
169
216
|
index = {"schema": SCHEMA, "editions": list(editions.values()),
|
|
170
|
-
"audits": {r: {k: a[k] for k in ("state", "detail", "commit", "release", "author", "url", "gates"
|
|
217
|
+
"audits": {r: {k: a[k] for k in ("state", "detail", "commit", "release", "author", "url", "gates",
|
|
218
|
+
"paper_version") if k in a}
|
|
171
219
|
for r, a in audits_loaded.items()}, "mode": "paper", "release": "paper", "evidence": eid,
|
|
172
220
|
"tool": {"name": "machinechecked"}, "project": {}, "projects": projects,
|
|
173
221
|
"paper": paper, "notes": [],
|
|
222
|
+
**({"version": version, "versions": offered} if offered else {}),
|
|
174
223
|
"papers": [{"id": "P", "title": paper.get("title", ""), "mode": "pdf", "pdf": None,
|
|
175
224
|
"pdf_url": pdf_url, "page_size": list(page_size) if page_size else None,
|
|
176
225
|
"note": ""}],
|
|
@@ -20,6 +20,7 @@ from .schemas import validate
|
|
|
20
20
|
from .sources import acquire
|
|
21
21
|
from .source_regions import collect as collect_source_regions
|
|
22
22
|
from .tex import DEFAULT_ENVS, TexError, anchors_for, theorem_envs
|
|
23
|
+
from . import versions as paper_versions
|
|
23
24
|
from .util import (canonical_json, git_dirty, git_head, link_or_copy, prepare_work_dir,
|
|
24
25
|
read_json, sha256_file, sha256_text, write_json)
|
|
25
26
|
|
|
@@ -62,6 +63,11 @@ def build(cfg: Config, release: str | None = None, skip_lean: bool = False,
|
|
|
62
63
|
# runs: a problem there should not wait for a probe that can take hours.
|
|
63
64
|
snaps = {paper.id: acquire(cfg, paper, cfg.out_dir / "sources" / paper.id)
|
|
64
65
|
for paper in cfg.papers}
|
|
66
|
+
# The version of each paper the audit pins, refused when the inventory pins another one.
|
|
67
|
+
versions = {}
|
|
68
|
+
for paper in cfg.papers:
|
|
69
|
+
rec, is_declared = paper_versions.declared(paper, snaps[paper.id], cfg.root)
|
|
70
|
+
versions[paper.id] = paper_versions.check(paper, rec, is_declared, inv)
|
|
65
71
|
|
|
66
72
|
lean = None
|
|
67
73
|
lean_digest = None
|
|
@@ -74,7 +80,8 @@ def build(cfg: Config, release: str | None = None, skip_lean: bool = False,
|
|
|
74
80
|
or (r["kind"] in ("accept", "refute", "witness") and
|
|
75
81
|
f"{r['kind']}:{r['name']}:{r.get('spec') or ''}" not in lean["proofs"])]
|
|
76
82
|
if missing:
|
|
77
|
-
raise
|
|
83
|
+
raise StaleEvidence(f"the stored Lean results do not cover {', '.join(missing[:5])}"
|
|
84
|
+
+ (", …" if len(missing) > 5 else "") + "; " + RUN_PROBE)
|
|
78
85
|
lean_digest = lean_inputs_digest(cfg)
|
|
79
86
|
log("probe: reusing the stored probe records (no Lean input changed)")
|
|
80
87
|
elif not skip_lean:
|
|
@@ -93,7 +100,8 @@ def build(cfg: Config, release: str | None = None, skip_lean: bool = False,
|
|
|
93
100
|
# A paper read from a folder: the commit of the repository that folder is in.
|
|
94
101
|
**({"source_commit": git_head(cfg.root / paper.source["path"])}
|
|
95
102
|
if snap.kind == "path" and git_head(cfg.root / paper.source["path"]) else {}),
|
|
96
|
-
**({"published_note": paper.published_note} if paper.published_note else {})
|
|
103
|
+
**({"published_note": paper.published_note} if paper.published_note else {}),
|
|
104
|
+
**({"paper_version": versions[paper.id]} if versions[paper.id] else {})}
|
|
97
105
|
t = None
|
|
98
106
|
if snap.mode == "latex" and not skip_tex:
|
|
99
107
|
envs = paper.envs or sorted(set(DEFAULT_ENVS) | set(theorem_envs(snap.dir)))
|
|
@@ -214,16 +222,17 @@ def reusable_lean(cfg: Config) -> dict:
|
|
|
214
222
|
content of every Lean input (here and in every path dependency) and the same probe."""
|
|
215
223
|
rels = ev.releases(cfg.out_dir)
|
|
216
224
|
if not rels:
|
|
217
|
-
raise
|
|
225
|
+
raise StaleEvidence("no stored Lean results to reuse; " + RUN_PROBE)
|
|
218
226
|
body = ev.load(cfg.out_dir, read_json(rels[-1])["evidence"])["body"]
|
|
219
227
|
lean, prov = body.get("lean"), body["provenance"]
|
|
220
228
|
if not lean or not prov.get("lean_inputs_sha256") or not prov.get("probe_sha256"):
|
|
221
|
-
raise
|
|
229
|
+
raise StaleEvidence("the stored Lean results do not record their Lean inputs; "
|
|
230
|
+
+ RUN_PROBE)
|
|
222
231
|
if prov["lean_inputs_sha256"] != lean_inputs_digest(cfg):
|
|
223
|
-
raise
|
|
224
|
-
|
|
232
|
+
raise StaleEvidence("Lean inputs changed since the stored Lean results (here or in a "
|
|
233
|
+
"path dependency); " + RUN_PROBE)
|
|
225
234
|
if prov["probe_sha256"] != probe_digest():
|
|
226
|
-
raise
|
|
235
|
+
raise StaleEvidence("the Lean probe changed since the stored Lean results; " + RUN_PROBE)
|
|
227
236
|
return lean
|
|
228
237
|
|
|
229
238
|
|
|
@@ -242,6 +251,7 @@ class StaleEvidence(RuntimeError):
|
|
|
242
251
|
|
|
243
252
|
|
|
244
253
|
NO_RELEASE = "no release: run `machinechecked build` first"
|
|
254
|
+
RUN_PROBE = "run `machinechecked build` without `--reuse-lean`"
|
|
245
255
|
|
|
246
256
|
|
|
247
257
|
def inventory_changed(cfg: Config, body: dict) -> str | None:
|
|
@@ -10,6 +10,7 @@ import re
|
|
|
10
10
|
from urllib.parse import quote, urlsplit, urljoin
|
|
11
11
|
|
|
12
12
|
from . import manifest as mf
|
|
13
|
+
from . import versions
|
|
13
14
|
from .status import fields, STATUSES
|
|
14
15
|
from .util import content_id
|
|
15
16
|
from .schemas import validate
|
|
@@ -34,6 +35,39 @@ def audit_version(desc: dict) -> str:
|
|
|
34
35
|
return content_id({k: desc.get(k) for k in ('schema', 'release', 'formalisation', 'papers', 'data')})
|
|
35
36
|
|
|
36
37
|
|
|
38
|
+
def paper_version(value) -> dict | None:
|
|
39
|
+
"""The paper version an audit's descriptor says it pins, rebuilt from its kind and
|
|
40
|
+
identifier: the label shown is the one MachineChecked gives that version, never a label the
|
|
41
|
+
audit supplies (a manuscript is never shown with a version number). `checked` is true only
|
|
42
|
+
when the audit says every claim's pin was checked against the version; an audit that does
|
|
43
|
+
not say so is read as unchecked."""
|
|
44
|
+
if value is None:
|
|
45
|
+
return None
|
|
46
|
+
if not isinstance(value, dict):
|
|
47
|
+
raise AuditError('Invalid paper version')
|
|
48
|
+
kind, vid, rev = value.get('kind'), value.get('id'), value.get('revision')
|
|
49
|
+
checked = value.get('checked') is True
|
|
50
|
+
if kind == 'manuscript':
|
|
51
|
+
if not isinstance(rev, str) or not versions.COMMIT.fullmatch(rev) or \
|
|
52
|
+
vid != 'manuscript:' + rev[:versions.SHORT]:
|
|
53
|
+
raise AuditError('Invalid manuscript version')
|
|
54
|
+
return {**versions.manuscript_record(rev), 'checked': checked}
|
|
55
|
+
if kind == 'published' and isinstance(vid, str) and vid:
|
|
56
|
+
rec = versions.published_version(('arXiv:' + vid[6:]) if vid.startswith('arxiv:') else vid)
|
|
57
|
+
if rec['id'] != vid:
|
|
58
|
+
raise AuditError('Invalid published version')
|
|
59
|
+
return {**rec, 'revision': rev if isinstance(rev, str) else None, 'checked': checked}
|
|
60
|
+
raise AuditError('Invalid paper version')
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def same_version(a: str, b: str) -> bool:
|
|
64
|
+
"""Whether two version identifiers name one version (a manuscript's commit may be given
|
|
65
|
+
abbreviated)."""
|
|
66
|
+
if a.startswith('manuscript:') and b.startswith('manuscript:'):
|
|
67
|
+
return versions.same_commit(a[11:], b[11:])
|
|
68
|
+
return a.lower() == b.lower()
|
|
69
|
+
|
|
70
|
+
|
|
37
71
|
def load_published_audit(paper: dict, project: dict, listing: dict, fetch) -> dict:
|
|
38
72
|
"""Fetch and validate one snapshot. ``fetch(url, byte_limit)`` returns bytes.
|
|
39
73
|
|
|
@@ -87,6 +121,11 @@ def load_published_audit(paper: dict, project: dict, listing: dict, fetch) -> di
|
|
|
87
121
|
expected_version = project.get('paper_version')
|
|
88
122
|
if expected_version and public.get('version') != expected_version:
|
|
89
123
|
raise AuditError('Audit paper version differs from the listing')
|
|
124
|
+
pinned = paper_version(public.get('paper_version'))
|
|
125
|
+
# A listing that names the version it lists this audit under (`version`, an identifier as
|
|
126
|
+
# `paper_version.id` gives it) needs an audit that pins that version.
|
|
127
|
+
if listing.get('version') and not (pinned and same_version(listing['version'], pinned['id'])):
|
|
128
|
+
raise AuditError('Audit pins another version of the paper than the listing names')
|
|
90
129
|
raw_index = read(d['data'], 20_000_000)
|
|
91
130
|
idx = deepcopy(raw_index)
|
|
92
131
|
if idx.get('schema') != mf.SCHEMA:
|
|
@@ -106,6 +145,8 @@ def load_published_audit(paper: dict, project: dict, listing: dict, fetch) -> di
|
|
|
106
145
|
raise AuditError('Audit needs an unambiguous internal paper key')
|
|
107
146
|
ap = matched[0]
|
|
108
147
|
revision = ap.get('revision') or ap.get('source_commit')
|
|
148
|
+
if paper_version(ap.get('paper_version')) != pinned:
|
|
149
|
+
raise AuditError('Audit descriptor and data name different paper versions')
|
|
109
150
|
if not revision or revision != public.get('revision'):
|
|
110
151
|
raise AuditError('Audit paper revisions disagree')
|
|
111
152
|
rows = [c for c in idx.get('claims', []) if c.get('paper') == ap['id']]
|
|
@@ -157,6 +198,7 @@ def load_published_audit(paper: dict, project: dict, listing: dict, fetch) -> di
|
|
|
157
198
|
raise AuditError('Audit changed during download; retry the build')
|
|
158
199
|
return {'author': d.get('author') or listing.get('author'), 'url': base,
|
|
159
200
|
'commit': f['commit'], 'release': idx['release'], 'version': audit_version(d),
|
|
201
|
+
'paper_version': pinned,
|
|
160
202
|
'claims': records, 'store': store, 'pdfs': pdfs, 'paper': audited_paper,
|
|
161
203
|
'context': {k: idx.get(k) for k in ('release', 'evidence', 'project', 'lean', 'issues', 'site_url', 'created', 'tool')},
|
|
162
204
|
'gates': idx.get('gates', {}).get(ap['id']), 'state': 'loaded'}
|