machinechecked 0.1.15__tar.gz → 0.1.17__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.15 → machinechecked-0.1.17}/PKG-INFO +1 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/PKG-INFO +1 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/SOURCES.txt +3 -2
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/audit.py +8 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/cli.py +3 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/config.py +8 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/export.py +2 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/manifest.py +2 -2
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/paper.py +52 -3
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/pipeline.py +8 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/published.py +42 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/simple.py +88 -2
- machinechecked-0.1.17/engine/python/prooflens/versions.py +171 -0
- machinechecked-0.1.15/engine/python/prooflens/web/assets/index-B_fzeuBg.js → machinechecked-0.1.17/engine/python/prooflens/web/assets/index-B1CkNBtR.js +26 -26
- machinechecked-0.1.15/engine/python/prooflens/web/assets/index-e4I0NErR.css → machinechecked-0.1.17/engine/python/prooflens/web/assets/index-DKOP2F1S.css +1 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/index.html +2 -2
- {machinechecked-0.1.15 → machinechecked-0.1.17}/pyproject.toml +1 -1
- {machinechecked-0.1.15 → machinechecked-0.1.17}/LICENSE +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/README.md +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/dependency_links.txt +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/entry_points.txt +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/requires.txt +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/top_level.txt +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/__init__.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/__main__.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/assess.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/bundle.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/cache.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/ProofLensProbe.lean +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/prooflens.sty +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/schema/evidence.schema.json +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/schema/inventory.schema.json +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/schema/manifest-claim.schema.json +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/schema/manifest-index.schema.json +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/data/statuses.json +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/deps.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/evidence.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/formalization.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/pdfclaims.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/probe.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/promote.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/repin.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/replay.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/review_cli.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/review_queue.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/reviews.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/schemas.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/server.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/source_regions.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/sources.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/status.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/symbols.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/tex.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/util.py +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/engine/python/prooflens/web/theme.css +0 -0
- {machinechecked-0.1.15 → machinechecked-0.1.17}/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.17
|
|
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.15 → machinechecked-0.1.17}/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.17
|
|
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.15 → machinechecked-0.1.17}/engine/python/machinechecked.egg-info/SOURCES.txt
RENAMED
|
@@ -40,6 +40,7 @@ engine/python/prooflens/status.py
|
|
|
40
40
|
engine/python/prooflens/symbols.py
|
|
41
41
|
engine/python/prooflens/tex.py
|
|
42
42
|
engine/python/prooflens/util.py
|
|
43
|
+
engine/python/prooflens/versions.py
|
|
43
44
|
engine/python/prooflens/data/ProofLensProbe.lean
|
|
44
45
|
engine/python/prooflens/data/prooflens.sty
|
|
45
46
|
engine/python/prooflens/data/statuses.json
|
|
@@ -69,6 +70,6 @@ engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2
|
|
|
69
70
|
engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2
|
|
70
71
|
engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2
|
|
71
72
|
engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg
|
|
72
|
-
engine/python/prooflens/web/assets/index-
|
|
73
|
-
engine/python/prooflens/web/assets/index-
|
|
73
|
+
engine/python/prooflens/web/assets/index-B1CkNBtR.js
|
|
74
|
+
engine/python/prooflens/web/assets/index-DKOP2F1S.css
|
|
74
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 {
|
|
@@ -353,6 +353,9 @@ def _check_json(a):
|
|
|
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
355
|
"correspondence": c.get("correspondence"),
|
|
356
|
+
"reviews": [{"reviewer": r["reviewer"], "verdict": r["verdict"]["value"],
|
|
357
|
+
"submitted_at": r["submitted_at"], "current": r["current"]}
|
|
358
|
+
for r in c.get("reviews", [])],
|
|
356
359
|
"suggestions": [{"name": x["name"], "why": x.get("why")}
|
|
357
360
|
for x in c.get("suggestions", [])]}
|
|
358
361
|
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"),
|
|
@@ -282,7 +282,8 @@ def export(cfg: Config, out: Path, release: str | None = None,
|
|
|
282
282
|
for p in index["papers"]:
|
|
283
283
|
pub = pubs[p["id"]]
|
|
284
284
|
q = _pick(p, ["id", "title", "mode", "revision", "pdf_sha256", "page_size", "note",
|
|
285
|
-
"published", "published_note", "source_commit"
|
|
285
|
+
"published", "published_note", "source_commit",
|
|
286
|
+
"paper_version"])
|
|
286
287
|
q["root"] = p.get("root") if pub.source_text else None
|
|
287
288
|
q["pdf"] = p["pdf"] if pub.pdf else None
|
|
288
289
|
pidx["papers"].append(q)
|
|
@@ -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
|
|
@@ -94,7 +100,8 @@ def build(cfg: Config, release: str | None = None, skip_lean: bool = False,
|
|
|
94
100
|
# A paper read from a folder: the commit of the repository that folder is in.
|
|
95
101
|
**({"source_commit": git_head(cfg.root / paper.source["path"])}
|
|
96
102
|
if snap.kind == "path" and git_head(cfg.root / paper.source["path"]) else {}),
|
|
97
|
-
**({"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 {})}
|
|
98
105
|
t = None
|
|
99
106
|
if snap.mode == "latex" and not skip_tex:
|
|
100
107
|
envs = paper.envs or sorted(set(DEFAULT_ENVS) | set(theorem_envs(snap.dir)))
|
|
@@ -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'}
|
|
@@ -261,7 +261,7 @@ def linked_names(claim: dict, entry: dict) -> list[str]:
|
|
|
261
261
|
return [n for n in names if n not in entry.get("rejected", [])]
|
|
262
262
|
|
|
263
263
|
|
|
264
|
-
COVERAGE = ("full", "partial", "changed", "related")
|
|
264
|
+
COVERAGE = ("full", "composed", "partial", "changed", "related", "unresolved")
|
|
265
265
|
CONFIDENCE = ("high", "medium", "low")
|
|
266
266
|
NOTE_CHARS = 2000
|
|
267
267
|
|
|
@@ -288,6 +288,71 @@ def correspondence(claim: dict, entry: dict) -> dict | None:
|
|
|
288
288
|
"note": " ".join(notes)[:NOTE_CHARS], "by": None}
|
|
289
289
|
|
|
290
290
|
|
|
291
|
+
REVIEWS_DIR = "machinechecked-reviews"
|
|
292
|
+
REVIEW_TEXT_CHARS = 20000
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def load_review_reports(root: Path) -> tuple[dict[str, list[dict]], list[str]]:
|
|
296
|
+
"""The review reports exported by the reader's Review page and kept in the project's
|
|
297
|
+
`machinechecked-reviews/` folder, by review unit (`link:<claim key>`), and a note for each
|
|
298
|
+
file that could not be read. A report's text is the reviewer's and is shown as text."""
|
|
299
|
+
out: dict[str, list[dict]] = {}
|
|
300
|
+
notes: list[str] = []
|
|
301
|
+
seen = set()
|
|
302
|
+
d = root / REVIEWS_DIR
|
|
303
|
+
for f in sorted(d.glob("*.json")) if d.is_dir() else []:
|
|
304
|
+
try:
|
|
305
|
+
data = json.loads(f.read_text(encoding="utf-8"))
|
|
306
|
+
reports = data["reports"] if data.get("schema") == "prooflens/review-reports@1" else None
|
|
307
|
+
if not isinstance(reports, list):
|
|
308
|
+
raise ValueError("not a review export")
|
|
309
|
+
except (OSError, ValueError, KeyError, AttributeError) as e:
|
|
310
|
+
notes.append(f"{REVIEWS_DIR}/{f.name} was skipped: {e}")
|
|
311
|
+
continue
|
|
312
|
+
for r in reports:
|
|
313
|
+
if not isinstance(r, dict) or r.get("schema") != "prooflens/review-report@1":
|
|
314
|
+
continue
|
|
315
|
+
unit = (r.get("unit") or {}).get("id")
|
|
316
|
+
key = (unit, (r.get("reviewer") or {}).get("id"), r.get("submitted_at"))
|
|
317
|
+
if not isinstance(unit, str) or key in seen:
|
|
318
|
+
continue
|
|
319
|
+
seen.add(key)
|
|
320
|
+
out.setdefault(unit, []).append(r)
|
|
321
|
+
return out, notes
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def _text(x) -> str:
|
|
325
|
+
return x[:REVIEW_TEXT_CHARS] if isinstance(x, str) else ""
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def review_view(r: dict, links: list[dict]) -> dict:
|
|
329
|
+
"""A report as the reader shows it, and whether it is current: it reviewed exactly the
|
|
330
|
+
claim's linked declarations, with the statements they have now (`None` when the Lean was
|
|
331
|
+
not checked, so their statements are unknown)."""
|
|
332
|
+
pins = r.get("pins") or {}
|
|
333
|
+
fps = pins.get("fingerprints") or {}
|
|
334
|
+
now = {}
|
|
335
|
+
for l in links:
|
|
336
|
+
rec = l.get("record") or {}
|
|
337
|
+
now[l["name"]] = rec.get("fingerprint") or (rec.get("decl") or {}).get("fingerprint")
|
|
338
|
+
if not links or any(v is None for v in now.values()):
|
|
339
|
+
current = None
|
|
340
|
+
else:
|
|
341
|
+
current = set(fps) == set(now) and all(fps[n] == now[n] for n in now)
|
|
342
|
+
rv, verdict = r.get("reviewer") or {}, r.get("verdict") or {}
|
|
343
|
+
return {"reviewer": {k: rv.get(k) for k in ("id", "kind", "name", "model", "identity",
|
|
344
|
+
"same_family_as_author")},
|
|
345
|
+
"verdict": {"group": verdict.get("group"), "value": verdict.get("value"),
|
|
346
|
+
"detail": _text(verdict.get("detail"))},
|
|
347
|
+
"reading": _text((r.get("reading") or {}).get("text")),
|
|
348
|
+
"comparison": _text((r.get("comparison") or {}).get("text")),
|
|
349
|
+
"checklist": (r.get("comparison") or {}).get("checklist") or {},
|
|
350
|
+
"locked_at": (r.get("reading") or {}).get("locked_at"),
|
|
351
|
+
"submitted_at": r.get("submitted_at"),
|
|
352
|
+
"reviewed": sorted(fps), "release": pins.get("release"),
|
|
353
|
+
"project_commit": pins.get("project_commit"), "current": current}
|
|
354
|
+
|
|
355
|
+
|
|
291
356
|
def link_source(claim: dict, entry: dict, name: str) -> str:
|
|
292
357
|
if "lean" in entry:
|
|
293
358
|
return "confirmed"
|
|
@@ -644,6 +709,8 @@ def build_view(root: Path, paper_path: Path, out_dir: Path, lake: str = "lake",
|
|
|
644
709
|
if st.get("module")}
|
|
645
710
|
c["declared_notes"] = [st["note"] for st in rows if st.get("note")]
|
|
646
711
|
links = load_links(root).get("papers", {}).get(paper_key, {})
|
|
712
|
+
reports, review_notes = load_review_reports(root)
|
|
713
|
+
notes += review_notes
|
|
647
714
|
if not libs:
|
|
648
715
|
notes.append("no Lean library found in the lakefile")
|
|
649
716
|
elif not built:
|
|
@@ -741,6 +808,7 @@ def build_view(root: Path, paper_path: Path, out_dir: Path, lake: str = "lake",
|
|
|
741
808
|
found = [r for r in linkrecs.get(s["name"], []) if "missing" not in r.get("errors", [])]
|
|
742
809
|
s["record"] = found[0] if len({((r.get("decl") or {}).get("module")) for r in found}) == 1 else None
|
|
743
810
|
c["correspondence"] = correspondence(c, entry) if c["links"] else None
|
|
811
|
+
c["reviews"] = [review_view(r, c["links"]) for r in reports.get("link:" + c["key"], [])]
|
|
744
812
|
if c["links"]:
|
|
745
813
|
worst = max(c["links"], key=lambda l: ["proved", "unspecified", "open", "malformed"]
|
|
746
814
|
.index(l["class"]))
|
|
@@ -830,7 +898,7 @@ def write_view_site(view: dict, site: Path, web_dist: Path | None,
|
|
|
830
898
|
"source_evidence": source_evidence({"kind": akind} if anchor else None, body["tex"]["mode"], paper=body["tex"]),
|
|
831
899
|
"blockers": [],
|
|
832
900
|
"links": [_link_view(l, root) for l in c["links"]],
|
|
833
|
-
"correspondence": c.get("correspondence"),
|
|
901
|
+
"correspondence": c.get("correspondence"), "reviews": c.get("reviews", []),
|
|
834
902
|
"suggestions": [_link_view(s, root) for s in c.get("suggestions", [])],
|
|
835
903
|
"clauses": [], "decls": {n: keys[n] for n in sorted(names) if n in keys},
|
|
836
904
|
"findings": []}
|
|
@@ -849,6 +917,7 @@ def write_view_site(view: dict, site: Path, web_dist: Path | None,
|
|
|
849
917
|
"lean": None, "notes": body["notes"],
|
|
850
918
|
"papers": [{"id": "P", "title": body["title"], "mode": body["tex"]["mode"],
|
|
851
919
|
"revision": body.get("commit"),
|
|
920
|
+
**_paper_version(body),
|
|
852
921
|
"pdf": "papers/P.pdf" if view["pdf"] else None,
|
|
853
922
|
"pdf_sha256": body.get("pdf_sha256") if view["pdf"] else None,
|
|
854
923
|
"page_size": body["tex"].get("page_size"), "note": ""}],
|
|
@@ -873,6 +942,23 @@ def write_view_site(view: dict, site: Path, web_dist: Path | None,
|
|
|
873
942
|
return index
|
|
874
943
|
|
|
875
944
|
|
|
945
|
+
def _paper_version(body: dict) -> dict:
|
|
946
|
+
"""The version of the paper the view reads: the arXiv version its URL names, else the
|
|
947
|
+
project's commit (the paper is a file of the project). Its claims are read from that
|
|
948
|
+
version itself, so the version is checked."""
|
|
949
|
+
from . import versions
|
|
950
|
+
from .audit import arxiv_id
|
|
951
|
+
key = body.get("paper") or ""
|
|
952
|
+
ax = arxiv_id(key) if key.startswith(("http://", "https://")) else None
|
|
953
|
+
if ax and ax[1]:
|
|
954
|
+
return {"paper_version": {**versions.published_version(f"arXiv:{ax[0][6:]}{ax[1]}"),
|
|
955
|
+
"checked": True}}
|
|
956
|
+
commit = body.get("commit") or ""
|
|
957
|
+
if versions.COMMIT.fullmatch(commit) and len(commit) == 40:
|
|
958
|
+
return {"paper_version": {**versions.manuscript_record(commit), "checked": True}}
|
|
959
|
+
return {}
|
|
960
|
+
|
|
961
|
+
|
|
876
962
|
def _link_view(l: dict, root: Path | None = None) -> dict:
|
|
877
963
|
"""A link or suggestion as the reader shows it; `path` is its file in the project's
|
|
878
964
|
repository, for a link to its source, when the project is known."""
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""The version of a paper an audit pins, and the check that the claim inventory pins the same one.
|
|
2
|
+
|
|
3
|
+
A version is either published (the version `published` names, such as `arXiv:2601.01234v1`, or
|
|
4
|
+
an arXiv source) or an unpublished manuscript at a commit (`version = "manuscript"`, with the
|
|
5
|
+
source's pinned revision). Its record says which, with a label for readers: "arXiv v1", or
|
|
6
|
+
"Latest manuscript (commit abc1234)". An unpublished manuscript is never given a version number.
|
|
7
|
+
|
|
8
|
+
The record is descriptive: no status depends on it. What is checked is that the inventory's pins
|
|
9
|
+
(`papers.<id>.commit`, a claim's `commit`) name the declared version: a published version by its
|
|
10
|
+
identifier (`2601.01234v1`), a manuscript by its commit. So an audit labelled with one version
|
|
11
|
+
cannot carry claims pinned to another. The record's `checked` says whether that check covers
|
|
12
|
+
every claim: it is false when some claim carries no pin, so the version is only as the
|
|
13
|
+
configuration states it, and readers are told so.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import re
|
|
19
|
+
import subprocess
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
|
|
22
|
+
from .audit import published_record
|
|
23
|
+
|
|
24
|
+
COMMIT = re.compile(r"[0-9a-f]{7,40}")
|
|
25
|
+
ARXIV_PIN = re.compile(r"(?:arxiv:)?([a-z-]+(?:\.[A-Z]{2})?/\d{7}|\d{4}\.\d{4,5})(v\d+)?", re.I)
|
|
26
|
+
SHORT = 7
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class VersionError(ValueError):
|
|
30
|
+
"""A paper's declared version is incomplete or disagrees with the inventory's pins."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def same_commit(a: str, b: str) -> bool:
|
|
34
|
+
"""Whether two commit names (full or abbreviated, at least 7 hexadecimal digits) agree."""
|
|
35
|
+
a, b = a.strip().lower(), b.strip().lower()
|
|
36
|
+
return a == b or bool(COMMIT.fullmatch(a) and COMMIT.fullmatch(b)
|
|
37
|
+
and (a.startswith(b) or b.startswith(a)))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _toplevel_head(folder: Path) -> str | None:
|
|
41
|
+
"""The commit checked out in `folder`, when `folder` is the top of its own Git work tree
|
|
42
|
+
(a folder inside another repository is not the manuscript's own history)."""
|
|
43
|
+
if not folder.is_dir():
|
|
44
|
+
return None
|
|
45
|
+
top = subprocess.run(["git", "rev-parse", "--show-toplevel"], cwd=folder,
|
|
46
|
+
capture_output=True, text=True)
|
|
47
|
+
if top.returncode != 0 or Path(top.stdout.strip()).resolve() != folder.resolve():
|
|
48
|
+
return None
|
|
49
|
+
head = subprocess.run(["git", "rev-parse", "HEAD"], cwd=folder, capture_output=True,
|
|
50
|
+
text=True)
|
|
51
|
+
return head.stdout.strip() if head.returncode == 0 else None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def manuscript_revision(paper, snap, base: Path) -> str | None:
|
|
55
|
+
"""The commit of the source the audit reads: a Git source's resolved `rev`; a folder's
|
|
56
|
+
stated `rev` (checked against the folder's own history when it has one), else the folder's
|
|
57
|
+
commit when it is a repository of its own."""
|
|
58
|
+
if snap.kind == "git":
|
|
59
|
+
return snap.revision
|
|
60
|
+
if snap.kind != "path":
|
|
61
|
+
return None
|
|
62
|
+
stated = paper.source.get("rev")
|
|
63
|
+
head = _toplevel_head((base / paper.source["path"]).resolve())
|
|
64
|
+
if stated and head and not same_commit(stated, head):
|
|
65
|
+
raise VersionError(f"paper {paper.id}: source rev {stated} is not the commit checked "
|
|
66
|
+
f"out in {paper.source['path']} ({head[:SHORT]})")
|
|
67
|
+
return str(stated) if stated else head
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def manuscript_record(revision: str) -> dict:
|
|
71
|
+
short = revision[:SHORT]
|
|
72
|
+
return {"kind": "manuscript", "id": f"manuscript:{short}", "revision": revision,
|
|
73
|
+
"label": f"Latest manuscript (commit {short})"}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def published_version(value: str) -> dict:
|
|
77
|
+
"""The record of a published version named as `published` names it."""
|
|
78
|
+
rec = published_record(value)
|
|
79
|
+
if rec["id"] and rec["id"].startswith("arxiv:"):
|
|
80
|
+
n = rec["version"]
|
|
81
|
+
return {"kind": "published", "id": rec["id"] + (n or ""), "arxiv": rec["id"],
|
|
82
|
+
"number": n, "label": f"arXiv {n}" if n else f"arXiv {rec['id'][6:]}"}
|
|
83
|
+
if rec["id"]:
|
|
84
|
+
return {"kind": "published", "id": rec["id"], "label": f"Published ({rec['id']})"}
|
|
85
|
+
return {"kind": "published", "id": rec["url"] or value, "label": "Published version"}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def declared(paper, snap, base: Path) -> tuple[dict | None, bool]:
|
|
89
|
+
"""The version this paper's audit pins, and whether the configuration declares it (a
|
|
90
|
+
declared version is checked against the inventory; an inferred one is dropped instead)."""
|
|
91
|
+
revision = manuscript_revision(paper, snap, base)
|
|
92
|
+
want = paper.version
|
|
93
|
+
source_arxiv = snap.revision if snap.kind == "arxiv" else None
|
|
94
|
+
if want == "published" or (want is None and (paper.published or source_arxiv)):
|
|
95
|
+
if source_arxiv:
|
|
96
|
+
rec = published_version("arXiv:" + source_arxiv)
|
|
97
|
+
if paper.published and published_version(paper.published)["id"] != rec["id"]:
|
|
98
|
+
raise VersionError(f"paper {paper.id}: published names {paper.published}, but "
|
|
99
|
+
f"the source is arXiv {source_arxiv}")
|
|
100
|
+
elif paper.published:
|
|
101
|
+
rec = published_version(paper.published)
|
|
102
|
+
else:
|
|
103
|
+
raise VersionError(f'paper {paper.id}: version = "published" needs `published`, '
|
|
104
|
+
'as in published = "arXiv:2601.01234v1"')
|
|
105
|
+
return {**rec, "revision": revision}, True
|
|
106
|
+
if want == "manuscript":
|
|
107
|
+
if snap.kind == "arxiv":
|
|
108
|
+
raise VersionError(f'paper {paper.id}: version = "manuscript", but the source is '
|
|
109
|
+
'arXiv; read the manuscript from its repository (git, rev)')
|
|
110
|
+
if not revision:
|
|
111
|
+
raise VersionError(f'paper {paper.id}: version = "manuscript" needs the commit of '
|
|
112
|
+
'the manuscript: give the source a `rev`')
|
|
113
|
+
return manuscript_record(revision), True
|
|
114
|
+
return (manuscript_record(revision) if revision else None), False
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def inventory_pins(inv: dict, pid: str) -> dict[str, list[str]]:
|
|
118
|
+
"""Each pin of the paper's claims (a claim's `commit`, else `papers.<id>.commit`), with the
|
|
119
|
+
claims it pins."""
|
|
120
|
+
default = ((inv.get("papers") or {}).get(pid) or {}).get("commit")
|
|
121
|
+
out: dict[str, list[str]] = {}
|
|
122
|
+
for c in inv.get("claims", []):
|
|
123
|
+
if c.get("paper") == pid and (c.get("commit") or default):
|
|
124
|
+
out.setdefault(str(c.get("commit") or default), []).append(c["id"])
|
|
125
|
+
return out
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def pin_matches(pin: str, rec: dict) -> bool:
|
|
129
|
+
"""Whether an inventory pin names the version `rec` records. A published version is named
|
|
130
|
+
by its own identifier (`2601.01234v1`, with or without `arXiv:`); a commit cannot show
|
|
131
|
+
which published version it is. A manuscript is named by its commit."""
|
|
132
|
+
pin = pin.strip()
|
|
133
|
+
if rec["kind"] == "published":
|
|
134
|
+
m = ARXIV_PIN.fullmatch(pin)
|
|
135
|
+
if m and not COMMIT.fullmatch(pin.lower()):
|
|
136
|
+
return ("arxiv:" + m.group(1) + (m.group(2) or "")).lower() == rec["id"].lower()
|
|
137
|
+
return pin.lower() == rec["id"].lower()
|
|
138
|
+
return bool(COMMIT.fullmatch(pin.lower()) and same_commit(pin, rec["revision"]))
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def describe_pin(pin: str) -> str:
|
|
142
|
+
return f"commit {pin[:SHORT]}" if COMMIT.fullmatch(pin.lower()) else pin
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def unpinned_claims(inv: dict, pid: str) -> list[str]:
|
|
146
|
+
"""The paper's claims that carry no pin (neither their own `commit` nor the paper's)."""
|
|
147
|
+
if ((inv.get("papers") or {}).get(pid) or {}).get("commit"):
|
|
148
|
+
return []
|
|
149
|
+
return [c["id"] for c in inv.get("claims", []) if c.get("paper") == pid and not c.get("commit")]
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def check(paper, rec: dict | None, is_declared: bool, inv: dict) -> dict | None:
|
|
153
|
+
"""The version record to publish: `rec` when the inventory's pins agree with it, with
|
|
154
|
+
`checked` false when some claim carries no pin to check it against (or there are no claims).
|
|
155
|
+
A declared version the pins disagree with is refused; an inferred one is dropped (nothing is
|
|
156
|
+
claimed)."""
|
|
157
|
+
if rec is None:
|
|
158
|
+
return None
|
|
159
|
+
pins = inventory_pins(inv, paper.id)
|
|
160
|
+
bad = {pin: ids for pin, ids in pins.items() if not pin_matches(pin, rec)}
|
|
161
|
+
if not bad:
|
|
162
|
+
return {**rec, "checked": bool(pins) and not unpinned_claims(inv, paper.id)}
|
|
163
|
+
if not is_declared:
|
|
164
|
+
return None
|
|
165
|
+
pins = "; ".join(f"{describe_pin(p)} ({len(ids)} claim{'s' * (len(ids) != 1)}, "
|
|
166
|
+
f"such as {ids[0]})" for p, ids in sorted(bad.items()))
|
|
167
|
+
fix = ('pin the inventory to ' + (rec['id'].removeprefix('arxiv:') if rec['kind'] ==
|
|
168
|
+
'published' else f"commit {rec['revision'][:SHORT]}")
|
|
169
|
+
+ ', or declare the version the inventory pins (`version` and the source\'s `rev`)')
|
|
170
|
+
raise VersionError(f"paper {paper.id}: the audit pins {rec['label']}, but its inventory is "
|
|
171
|
+
f"pinned to {pins}. An audit pins one version of its paper: {fix}.")
|