machinechecked 0.1.26__tar.gz → 0.1.27__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.
Files changed (116) hide show
  1. {machinechecked-0.1.26 → machinechecked-0.1.27}/PKG-INFO +1 -1
  2. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/machinechecked.egg-info/PKG-INFO +1 -1
  3. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/machinechecked.egg-info/SOURCES.txt +1 -0
  4. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/cli.py +202 -35
  5. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/config.py +22 -0
  6. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/export.py +7 -1
  7. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/review_cli.py +5 -4
  8. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/review_snapshot.py +233 -18
  9. machinechecked-0.1.27/engine/python/prooflens/snapshot_text.py +438 -0
  10. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/sources.py +9 -5
  11. {machinechecked-0.1.26 → machinechecked-0.1.27}/pyproject.toml +1 -1
  12. {machinechecked-0.1.26 → machinechecked-0.1.27}/LICENSE +0 -0
  13. {machinechecked-0.1.26 → machinechecked-0.1.27}/README.md +0 -0
  14. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/machinechecked.egg-info/dependency_links.txt +0 -0
  15. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/machinechecked.egg-info/entry_points.txt +0 -0
  16. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/machinechecked.egg-info/requires.txt +0 -0
  17. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/machinechecked.egg-info/top_level.txt +0 -0
  18. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/__init__.py +0 -0
  19. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/__main__.py +0 -0
  20. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/assess.py +0 -0
  21. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/audit.py +0 -0
  22. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/authoring.py +0 -0
  23. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/bundle.py +0 -0
  24. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/cache.py +0 -0
  25. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/changes.py +0 -0
  26. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/compare.py +0 -0
  27. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/composition.py +0 -0
  28. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/connections.py +0 -0
  29. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/content.py +0 -0
  30. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/ProofLensProbe.lean +0 -0
  31. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/prooflens.sty +0 -0
  32. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/schema/evidence.schema.json +0 -0
  33. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/schema/inventory.schema.json +0 -0
  34. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/schema/manifest-claim.schema.json +0 -0
  35. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/schema/manifest-index.schema.json +0 -0
  36. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/schema/published-work.schema.json +0 -0
  37. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/semantic.json +0 -0
  38. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/data/statuses.json +0 -0
  39. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/dependencies.py +0 -0
  40. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/deps.py +0 -0
  41. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/estimates.py +0 -0
  42. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/evidence.py +0 -0
  43. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/excerpt.py +0 -0
  44. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/expressions.py +0 -0
  45. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/facts.py +0 -0
  46. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/formalization.py +0 -0
  47. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/impact.py +0 -0
  48. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/layout.py +0 -0
  49. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/ledger.py +0 -0
  50. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/manifest.py +0 -0
  51. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/moddocs.py +0 -0
  52. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/notation_plan.py +0 -0
  53. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/numbering.py +0 -0
  54. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/objects.py +0 -0
  55. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/paper.py +0 -0
  56. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/pdfclaims.py +0 -0
  57. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/pipeline.py +0 -0
  58. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/probe.py +0 -0
  59. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/promote.py +0 -0
  60. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/proof_facts.py +0 -0
  61. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/published.py +0 -0
  62. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/published_work.py +0 -0
  63. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/readable.py +0 -0
  64. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/rebound.py +0 -0
  65. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/reopen.py +0 -0
  66. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/repin.py +0 -0
  67. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/replay.py +0 -0
  68. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/requirements.py +0 -0
  69. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/retire.py +0 -0
  70. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/retrieval.py +0 -0
  71. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/review_citations.py +0 -0
  72. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/review_queue.py +0 -0
  73. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/review_sources.py +0 -0
  74. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/reviews.py +0 -0
  75. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/schemas.py +0 -0
  76. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/semantic.py +0 -0
  77. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/server.py +0 -0
  78. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/simple.py +0 -0
  79. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/source_names.py +0 -0
  80. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/source_regions.py +0 -0
  81. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/status.py +0 -0
  82. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/steps.py +0 -0
  83. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/symbols.py +0 -0
  84. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/targets.py +0 -0
  85. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/tex.py +0 -0
  86. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/uses.py +0 -0
  87. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/util.py +0 -0
  88. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/version_map.py +0 -0
  89. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/versions.py +0 -0
  90. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  91. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  92. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  93. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  94. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  95. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  96. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  97. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  98. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  99. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  100. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  101. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  102. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  103. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  104. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  105. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  106. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  107. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  108. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  109. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/cursor-editorTextHighlight-kG3uUOwL.svg +0 -0
  110. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/index-DTkF_ivv.css +0 -0
  111. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/index-eKJREZT-.js +0 -0
  112. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/assets/pdf.worker.min-yatZIOMy.mjs +0 -0
  113. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/index.html +0 -0
  114. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/web/theme.css +0 -0
  115. {machinechecked-0.1.26 → machinechecked-0.1.27}/engine/python/prooflens/workspace.py +0 -0
  116. {machinechecked-0.1.26 → machinechecked-0.1.27}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machinechecked
3
- Version: 0.1.26
3
+ Version: 0.1.27
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: machinechecked
3
- Version: 0.1.26
3
+ Version: 0.1.27
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
@@ -64,6 +64,7 @@ engine/python/prooflens/schemas.py
64
64
  engine/python/prooflens/semantic.py
65
65
  engine/python/prooflens/server.py
66
66
  engine/python/prooflens/simple.py
67
+ engine/python/prooflens/snapshot_text.py
67
68
  engine/python/prooflens/source_names.py
68
69
  engine/python/prooflens/source_regions.py
69
70
  engine/python/prooflens/sources.py
@@ -1526,9 +1526,13 @@ def _forget_indexes(cfg) -> None:
1526
1526
 
1527
1527
 
1528
1528
  def cmd_build(a):
1529
+ """`build`, then the review snapshot the project keeps, if it keeps one
1530
+ (`_refresh_snapshot`)."""
1529
1531
  if not _assurance_config(a):
1530
- return _build_simple(a)
1532
+ _build_simple(a)
1533
+ return _refresh_snapshot(a)
1531
1534
  _build_full(a, site=a.site, refresh=a.refresh, fail_on_violation=a.fail_on_violation,
1535
+ then=lambda: _refresh_snapshot(a),
1532
1536
  release=a.release, skip_lean=a.skip_lean, skip_tex=a.skip_tex, lake=a.lake,
1533
1537
  lean_build=not a.no_lean_build, reuse_lean=a.reuse_lean)
1534
1538
 
@@ -1546,10 +1550,11 @@ def _assess(a, cfg, fix_modules: bool = False, **settings):
1546
1550
 
1547
1551
 
1548
1552
  def _build_full(a, site: str | None = None, refresh: bool = False, fix_modules: bool = False,
1549
- fail_on_violation: bool = False, **settings):
1553
+ fail_on_violation: bool = False, then=None, **settings):
1550
1554
  """`build`, and `check` without --json, with a machinechecked.toml: build and assess
1551
1555
  (`_assess`), print each paper's statuses and what blocks acceptance, and with `site` write
1552
- the audit's public export there. With `fail_on_violation`, exit 1 on a violation."""
1556
+ the audit's public export there; then `then()`, when given. With `fail_on_violation`, exit
1557
+ 1 on a violation."""
1553
1558
  cfg = _load_full(a)
1554
1559
  dest = _site_dest(site, cfg.root) if site else None
1555
1560
  if refresh:
@@ -1566,6 +1571,8 @@ def _build_full(a, site: str | None = None, refresh: bool = False, fix_modules:
1566
1571
  sys.exit(str(e))
1567
1572
  print(f"wrote the audit to {out['out']}: publish this directory as it is "
1568
1573
  "(audit.json describes it)")
1574
+ if then is not None:
1575
+ then()
1569
1576
  if fail_on_violation and res["index"]["findings"]["total"].get("violation"):
1570
1577
  sys.exit(1)
1571
1578
 
@@ -2324,38 +2331,113 @@ REVIEW_STEPS = {
2324
2331
  }
2325
2332
 
2326
2333
 
2334
+ def _review_project(a) -> tuple[Path, Path, Path, Path, bool]:
2335
+ """The project here, for the review commands and the snapshot it keeps: the working
2336
+ directory of its build and its Lean project (`_built_work`), its root (the configuration's
2337
+ directory, or the Lean project in zero configuration), the review snapshot it keeps
2338
+ (`[review] snapshot`, else `review-snapshot/` at its root: `review_snapshot.project_path`)
2339
+ and whether its configuration names that. Only the configuration is read: nothing is built
2340
+ or run."""
2341
+ from .review_snapshot import project_path
2342
+ work, lean = _built_work(a)
2343
+ if _assurance_config(a):
2344
+ cfg = _load_full(a)
2345
+ return (work, lean, cfg.root, project_path(cfg.root, cfg.review_snapshot),
2346
+ cfg.review_snapshot is not None)
2347
+ return work, lean, lean, project_path(lean), False
2348
+
2349
+
2350
+ def _shown(p: Path) -> str:
2351
+ """A directory as a command names it: relative to the current directory when inside it."""
2352
+ p = Path(p).resolve()
2353
+ try:
2354
+ return p.relative_to(Path.cwd().resolve()).as_posix() + "/"
2355
+ except ValueError:
2356
+ return p.as_posix() + "/"
2357
+
2358
+
2359
+ def _open_snapshot(snapshot: Path, work: Path, a, root: Path | None) -> tuple[Path, dict]:
2360
+ """The snapshot's site data and provenance, checked (`review_snapshot.open_snapshot`), with
2361
+ the reviewer's working directory `work` made; a refusal is the step's, of kind `snapshot`.
2362
+ A paper's text the snapshot leaves out is read from the paper's source
2363
+ (`snapshot_text.with_text`: --paper-source, or the project's folder at `root`); a source that
2364
+ cannot be obtained, or that differs, refuses the step with kind `paper-source`."""
2365
+ from . import review_cli as rc
2366
+ from . import review_snapshot as rs
2367
+ from . import snapshot_text as st
2368
+ try:
2369
+ rs.check_work_dir(work, snapshot)
2370
+ data, evidence = rs.open_snapshot(snapshot, work)
2371
+ rs.prepare_work_dir(work)
2372
+ except rs.SnapshotError as e:
2373
+ raise rc.ReviewError(str(e), "snapshot") from None
2374
+ try:
2375
+ data, said = st.with_text(data, work, getattr(a, "paper_source", None), root)
2376
+ except st.PaperSourceError as e:
2377
+ raise rc.ReviewError(str(e), "paper-source") from None
2378
+ for line in said:
2379
+ print(f"note: {line}", file=sys.stderr)
2380
+ return data, evidence
2381
+
2382
+
2327
2383
  def _review_target(a) -> tuple[Path, Path | None, Path | None, dict | None]:
2328
2384
  """Where a review step works: the working directory, the site data (None: the working
2329
2385
  directory's own), the Lean project and, for a review snapshot, its provenance. With
2330
2386
  --snapshot, the snapshot checked against its manifest and a working directory of the
2331
2387
  reviewer's own (`review_snapshot`); no configuration or Lean project is read. Otherwise the
2332
- last build of the project here (`_built_work`)."""
2388
+ last build of the project here (`_review_project`) when there is one, else the review
2389
+ snapshot the project keeps, checked as with --snapshot, with the reviewer's working
2390
+ directory at the project's root. Standard error says which, when the project keeps a
2391
+ snapshot."""
2333
2392
  from . import review_cli as rc
2334
2393
  from . import review_snapshot as rs
2335
- if not getattr(a, "snapshot", None):
2336
- if getattr(a, "review_dir", None):
2337
- raise rc.ReviewError("--review-dir is the working directory of a review of a "
2338
- "snapshot: give --snapshot FILE too", "invalid")
2394
+ if getattr(a, "snapshot", None):
2395
+ if getattr(a, "config", None):
2396
+ raise rc.ReviewError("--snapshot reviews the snapshot alone, with no configuration: "
2397
+ "leave out -c", "invalid")
2398
+ work = Path(a.review_dir or rs.REVIEW_DIR).resolve()
2399
+ data, evidence = _open_snapshot(Path(a.snapshot), work, a, None)
2400
+ return work, data, None, evidence
2401
+ no_dir = rc.ReviewError("--review-dir is the working directory of a review of a snapshot: "
2402
+ "give --snapshot FILE too", "invalid")
2403
+ try:
2404
+ work, root, top, snap, _ = _review_project(a)
2405
+ except SystemExit as e:
2406
+ # No project here: the command cannot run, and a snapshot, which needs no project,
2407
+ # is the way to review one built elsewhere.
2408
+ if e.code == NO_PROJECT:
2409
+ if getattr(a, "review_dir", None):
2410
+ raise no_dir from None
2411
+ sys.exit(f"machinechecked: {rc.NO_BUILD}")
2412
+ raise
2413
+ queue = work / "site" / "data" / "review-queue.json"
2414
+ built, kept = queue.is_file(), rs.kept(snap)
2415
+ if getattr(a, "review_dir", None) and (built or not kept):
2416
+ raise no_dir if not built else rc.ReviewError(
2417
+ "--review-dir is the working directory of a review of a snapshot, and the review "
2418
+ "here is of this project's own build: leave out --review-dir, or give --snapshot "
2419
+ "FILE", "invalid")
2420
+ if built and getattr(a, "paper_source", None):
2421
+ raise rc.ReviewError("--paper-source is for a review of a snapshot that leaves out the "
2422
+ "paper's text, and the review here is of this project's own "
2423
+ "build, which holds it: leave out --paper-source", "invalid")
2424
+ if built and kept:
2339
2425
  try:
2340
- work, root = _built_work(a)
2341
- except SystemExit as e:
2342
- # No project here: the command cannot run, and a snapshot, which needs no project,
2343
- # is the way to review one built elsewhere.
2344
- if e.code == NO_PROJECT:
2345
- sys.exit(f"machinechecked: {rc.NO_BUILD}")
2346
- raise
2426
+ rel = json.loads(queue.read_text(encoding="utf-8")).get("release")
2427
+ except (OSError, ValueError, AttributeError):
2428
+ rel = None
2429
+ print(f"note: reviewing this project's build ({_shown(work)}"
2430
+ + (f", release {rel}" if rel else "")
2431
+ + f"), not its review snapshot {_shown(snap)}", file=sys.stderr)
2432
+ if built or not kept:
2433
+ # Without a build or a snapshot, the session says there is nothing to review.
2347
2434
  return work, None, root, None
2348
- if getattr(a, "config", None):
2349
- raise rc.ReviewError("--snapshot reviews the snapshot alone, with no configuration: "
2350
- "leave out -c", "invalid")
2351
- work = Path(a.review_dir or rs.REVIEW_DIR).resolve()
2352
- try:
2353
- rs.check_work_dir(work, Path(a.snapshot))
2354
- data, evidence = rs.open_snapshot(Path(a.snapshot), work)
2355
- rs.prepare_work_dir(work)
2356
- except rs.SnapshotError as e:
2357
- raise rc.ReviewError(str(e), "snapshot") from None
2358
- return work, data, None, evidence
2435
+ rwork = Path(a.review_dir).resolve() if getattr(a, "review_dir", None) else top / rs.REVIEW_DIR
2436
+ data, evidence = _open_snapshot(snap, rwork, a, top)
2437
+ print(f"note: reviewing the project's review snapshot {_shown(snap)} (release "
2438
+ f"{evidence.get('release')}), as there is no build here; your work is kept in "
2439
+ f"{_shown(rwork)}", file=sys.stderr)
2440
+ return rwork, data, None, evidence
2359
2441
 
2360
2442
 
2361
2443
  def cmd_review_step(a):
@@ -2382,14 +2464,86 @@ def cmd_review_step(a):
2382
2464
 
2383
2465
  def cmd_review_pack(a):
2384
2466
  """Write a review snapshot of the last build (`review_snapshot.pack`), for a reviewer who
2385
- did not build the project, and say what it holds."""
2467
+ did not build the project, and say what it holds: to --out, else to the snapshot the project
2468
+ keeps (`_review_project`)."""
2386
2469
  from . import review_snapshot as rs
2387
- work, _ = _built_work(a)
2470
+ work, _, top, snap, _ = _review_project(a)
2471
+ out = Path(a.out) if a.out else snap
2472
+ if a.with_paper_text and out.resolve() == snap.resolve():
2473
+ sys.exit("machinechecked: --with-paper-text is for a snapshot you hand over privately, "
2474
+ f"and {_shown(snap)} is the snapshot the project keeps, which follows each "
2475
+ "paper's publish.source_text: give --out FILE")
2388
2476
  try:
2389
- m = rs.pack(work / "site" / "data", Path(a.out), pdf=a.pdf, tool=tool_version())
2477
+ m = rs.pack(work / "site" / "data", out, pdf=a.pdf, tool=tool_version(),
2478
+ **_paper_text(a, work, a.with_paper_text))
2390
2479
  except rs.SnapshotError as e:
2391
2480
  sys.exit(f"machinechecked: {e}")
2392
- print(rs.summary_text(m))
2481
+ # The path a reviewer gives from the project's root, or the one given here when it is
2482
+ # outside the project.
2483
+ try:
2484
+ given = out.resolve().relative_to(top.resolve()).as_posix()
2485
+ except ValueError:
2486
+ given = str(out)
2487
+ print(rs.summary_text(m, kept_here=out.resolve() == snap.resolve(), given=given))
2488
+
2489
+
2490
+ def _paper_text(a, work: Path, with_text: bool = False) -> dict:
2491
+ """What a snapshot of the full assessment here does with each paper's text (`pack`'s
2492
+ `without` and `kept_text`): left out when its `publish.source_text` is false, with the build's
2493
+ copy of its source and what names that source; kept when it is published, when the paper is
2494
+ read from its PDF, or with `with_text`. In zero configuration every paper's text is kept, as
2495
+ its published site keeps it."""
2496
+ if not _assurance_config(a):
2497
+ return {}
2498
+ from .sources import ARXIV_VERSIONED
2499
+ cfg = _load_full(a)
2500
+ try:
2501
+ index = json.loads((work / "site" / "data" / "index.json").read_text(encoding="utf-8"))
2502
+ except (OSError, ValueError):
2503
+ return {} # no build: `pack` says so
2504
+ built = {p.get("id"): p for p in index.get("papers") or []}
2505
+ without, kept = {}, {}
2506
+ for p in cfg.papers:
2507
+ if with_text:
2508
+ kept[p.id] = "asked"
2509
+ elif p.publish.source_text:
2510
+ kept[p.id] = "published"
2511
+ elif (built.get(p.id) or {}).get("mode") == "pdf":
2512
+ kept[p.id] = "pdf"
2513
+ else:
2514
+ src = p.source
2515
+ if "arxiv" in src:
2516
+ m = ARXIV_VERSIONED.fullmatch(str(src["arxiv"]).strip())
2517
+ spec = {"kind": "arxiv", "arxiv": m.group(1) + m.group(2) if m else src["arxiv"]}
2518
+ elif "path" in src:
2519
+ spec = {"kind": "path", "path": str(src["path"])}
2520
+ else:
2521
+ # The repository is not named: it may be private.
2522
+ spec = {"kind": "git", "revision": (built.get(p.id) or {}).get("revision")}
2523
+ without[p.id] = {"dir": cfg.out_dir / "sources" / p.id, "source": spec}
2524
+ return {"without": without, "kept_text": kept}
2525
+
2526
+
2527
+ def _refresh_snapshot(a) -> None:
2528
+ """After a build, the review snapshot the project keeps (`_review_project`), written again
2529
+ through `review pack` when the configuration names it or its directory is there (empty, or
2530
+ holding a snapshot), with the PDFs when the one there holds them; a snapshot that holds the
2531
+ build's review material already is left as it is. Nothing is written for a project that
2532
+ keeps none. A configured snapshot that cannot be written stops the command."""
2533
+ from . import review_snapshot as rs
2534
+ work, _, _, snap, configured = _review_project(a)
2535
+ if not configured and not snap.is_dir():
2536
+ return
2537
+ if not configured and not rs.kept(snap) and any(snap.iterdir()):
2538
+ print(f"note: {_shown(snap)} holds no review snapshot: the build left it as it is",
2539
+ file=sys.stderr)
2540
+ return
2541
+ try:
2542
+ m = rs.pack(work / "site" / "data", snap, pdf=rs.packed_pdf(snap), tool=tool_version(),
2543
+ **_paper_text(a, work))
2544
+ except rs.SnapshotError as e:
2545
+ sys.exit(f"machinechecked: the review snapshot {_shown(snap)} was not written: {e}")
2546
+ print(rs.refresh_line(m, _shown(snap)))
2393
2547
 
2394
2548
 
2395
2549
  def cmd_review_promote(a):
@@ -2606,11 +2760,16 @@ def _add_review(sub) -> None:
2606
2760
  pm.set_defaults(func=cmd_review_promote)
2607
2761
  pk = rvs.add_parser("pack", help="write a review snapshot of the last build, for a reviewer "
2608
2762
  "who did not build the project and has no Lean (author)")
2609
- pk.add_argument("--out", required=True, metavar="FILE",
2763
+ pk.add_argument("--out", metavar="FILE",
2610
2764
  help="the snapshot: a .zip file to send or attach to a release, or a "
2611
- "directory")
2765
+ "directory (default: the snapshot the project keeps, `[review] "
2766
+ "snapshot` or review-snapshot/ at its root)")
2612
2767
  pk.add_argument("--pdf", action="store_true",
2613
2768
  help="include the paper's PDF (left out by default)")
2769
+ pk.add_argument("--with-paper-text", action="store_true",
2770
+ help="keep the text of every paper's source, also of a paper whose "
2771
+ "publish.source_text is false (for a snapshot you hand over "
2772
+ "privately; not for the snapshot the project keeps)")
2614
2773
  _config_option(pk)
2615
2774
  pk.set_defaults(func=cmd_review_pack)
2616
2775
  rp = rvs.add_parser("reports", help="write the promoted reports as readable text "
@@ -2688,10 +2847,18 @@ def _add_review(sub) -> None:
2688
2847
  "interpretations, so no step is locked and the report says so")
2689
2848
  sp.add_argument("--snapshot", metavar="FILE",
2690
2849
  help="review the author's review snapshot (`review pack`: a .zip or a "
2691
- "directory) instead of a build here; needs no Lean")
2850
+ "directory) instead of a build here; needs no Lean. Without it, "
2851
+ "a project with no build here is reviewed from the snapshot it "
2852
+ "keeps (review-snapshot/), if any")
2853
+ sp.add_argument("--paper-source", action="append", metavar="[PAPER=]FILE",
2854
+ help="for a snapshot that leaves out a paper's text: that paper's "
2855
+ "source (its folder, or the file arXiv serves), from which each "
2856
+ "passage is read and checked; kept in your working directory for "
2857
+ "the later steps")
2692
2858
  sp.add_argument("--review-dir", metavar="DIR",
2693
- help="with --snapshot: the directory your work is kept in (default: "
2694
- f"{REVIEW_DIR}/ here)")
2859
+ help="for a review of a snapshot: the directory your work is kept in "
2860
+ f"(default: {REVIEW_DIR}/ here, or at the root of the project "
2861
+ "whose snapshot it is)")
2695
2862
  _config_option(sp)
2696
2863
  sp.set_defaults(func=cmd_review_step)
2697
2864
 
@@ -102,6 +102,9 @@ class Config:
102
102
  # The auditor's ledger of readings, whose rows name declarations and the revision they were
103
103
  # read at (`ledger.py`); `check` lists the rows those declarations' changes made stale.
104
104
  readings_ledger: Path | None = None
105
+ # The directory, inside the project, its review snapshot is kept in (`[review] snapshot`),
106
+ # which `build` keeps current (`review_snapshot.project_path`); None when not set.
107
+ review_snapshot: Path | None = None
105
108
 
106
109
  @property
107
110
  def root(self) -> Path:
@@ -214,9 +217,28 @@ def load(path: str | Path) -> Config:
214
217
  require_witness_def_reviews=_flag(proj, "require_witness_def_reviews", str(path)),
215
218
  readings_ledger=(base / proj["readings_ledger"]).resolve()
216
219
  if "readings_ledger" in proj else None,
220
+ review_snapshot=_snapshot_dir(raw.get("review", {}), base, str(path)),
217
221
  )
218
222
 
219
223
 
224
+ def _snapshot_dir(review: dict, base: Path, where: str) -> Path | None:
225
+ """`[review] snapshot`: a directory relative to the project's root, inside it, that is not
226
+ the root itself (None when it is not set)."""
227
+ if "snapshot" not in review:
228
+ return None
229
+ v = review["snapshot"]
230
+ if not isinstance(v, str) or not v.strip() or Path(v).is_absolute():
231
+ raise ConfigError(f"{where}: [review] snapshot must be a directory relative to the "
232
+ "project's root")
233
+ p, root = (base / v).resolve(), base.resolve()
234
+ if p == root or not p.is_relative_to(root):
235
+ raise ConfigError(f"{where}: [review] snapshot must be a directory inside the project, "
236
+ f"not {v!r}")
237
+ if p.suffix.lower() == ".zip":
238
+ raise ConfigError(f"{where}: [review] snapshot is a directory, not a .zip archive")
239
+ return p
240
+
241
+
220
242
  # The `[project]` header, and the line that opens its `modules` array (`check --fix-modules`).
221
243
  _PROJECT_HEADER = re.compile(
222
244
  r"""[ \t]*\[[ \t]*(?:project|"project"|'project')[ \t]*\][ \t]*(?:#.*)?""")
@@ -275,8 +275,14 @@ def scan(out: Path, texts: list[Path], hashes: set[str],
275
275
  except json.JSONDecodeError:
276
276
  pass
277
277
  found = None
278
+ # Every string of the file in one, so that a line absent from all of them, the usual
279
+ # case, is ruled out by one search; a line with the separator is looked for in each.
280
+ joined = "\0".join(v for _, v in fields)
278
281
  for s, src in lines.items():
279
- where = next((path for path, v in fields if s in v), None)
282
+ if "\0" in s or s in joined:
283
+ where = next((path for path, v in fields if s in v), None)
284
+ else:
285
+ where = None
280
286
  if where is not None or s in text:
281
287
  found = f"a line of {src.name}" + (f" (in {where})" if where else "")
282
288
  break
@@ -82,10 +82,11 @@ COVERAGE_FOR = {"matches": ("full", "partial"), "problem": ("partial", "changed"
82
82
 
83
83
  class ReviewError(RuntimeError):
84
84
  """A step refused, with what to do instead. `kind` says why: `no-build`, `snapshot` (a
85
- review snapshot that is incomplete, inconsistent or of another format), `unknown-unit`,
86
- `order` (a step before the one it follows), `reported`, `invalid`, `stale` (the build
87
- changed since the material was shown), `conflict` (the draft changed meanwhile; `conflicts`
88
- holds it as saved) or `workspace`."""
85
+ review snapshot that is incomplete, inconsistent or of another format), `paper-source` (the
86
+ source of a paper whose text the snapshot leaves out, not obtained or not the one it was
87
+ made from), `unknown-unit`, `order` (a step before the one it follows), `reported`,
88
+ `invalid`, `stale` (the build changed since the material was shown), `conflict` (the draft
89
+ changed meanwhile; `conflicts` holds it as saved) or `workspace`."""
89
90
 
90
91
  def __init__(self, message: str, kind: str = "refused", conflicts: list | None = None):
91
92
  super().__init__(message)