Add paperspec correct, check math forms and datasets, and give the tools public names

The work the other paper tools planned for paperspec (paperdesk PLAN M5.4,
paperform PLAN 4.2):

- paperspec correct and paperspec.revision apply proposed corrections to a
  package, folder or zip, and write it only once it validates.
- doc.math.form is checked: label and style commands always, the form's own
  spelling when papermath is installed or forms= is passed.
- paperspec.datasets and seven doc.dataset.* rules check a package's datasets.
- fixtures/invalid gains suspect-witness and math-form-label (33 in all).
- Canonical JSON reads numbers as doubles, so 1e20 round-trips.
- The registries and the JSON-LD context ship in the wheel.
- Public names for what paperdesk and paperform imported as private ones,
  with the old names kept as aliases.
- The text and lossy-projection functions are about three times faster
  through the gate, tested equal to the old code on every code point.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013XwDhn4LkrKQfw4ArDEr2E
This commit is contained in:
alexmandClaude committed 2026-10-20 22:10:17 -04:00
1 parent 8c07dd7c15
commit 4fb8b4f5a7
70 files changed
+4470 -270

No files matched your search

+48 -4
View File
@@ -4,8 +4,9 @@
# Source Code: https://git.scient.ing/papers/paperspec
# See the LICENSE.md file for full license terms.
"""Where the schemas, SQL and vectors are on disk (paperspec.resources)."""
"""Where the schemas, SQL, vectors, registries and context are on disk (paperspec.resources)."""
import json
import pathlib
import pytest
@@ -16,11 +17,21 @@ MARKERS = {
"schemas": "annotation.schema.json",
"sql": "doc.sql",
"vectors": "proofs.jsonl",
"registry": "stamps/scienting-stamps-1.json",
"context": "scienting-1.jsonld",
"fixtures": "packages/hale2026harmonic-damb/MANIFEST.json",
}
def test_the_folders_are_the_three_the_package_names():
assert resources.FOLDERS == ("schemas", "sql", "vectors")
def test_the_folders_are_the_six_the_package_names():
assert resources.FOLDERS == (
"schemas",
"sql",
"vectors",
"registry",
"context",
"fixtures",
)
@pytest.mark.parametrize("name", resources.FOLDERS)
@@ -32,7 +43,9 @@ def test_each_folder_is_found_and_holds_its_files(name):
@pytest.mark.parametrize("name", ["tests", "", "SCHEMAS", "schemas/", "../schemas"])
def test_any_other_name_is_refused_and_the_folders_are_listed(name):
with pytest.raises(ValueError, match="there are schemas, sql, vectors"):
with pytest.raises(
ValueError, match="there are schemas, sql, vectors, registry, context, fixtures"
):
resources.path(name)
@@ -71,3 +84,34 @@ def test_a_file_in_place_of_a_folder_is_not_a_folder(layout):
(layout / "schemas").write_text("not a folder", encoding="utf-8")
with pytest.raises(FileNotFoundError):
resources.path("schemas")
@pytest.mark.parametrize(
("name", "fmt"),
[
("stamps/scienting-stamps-1.json", "scienting-stamps/1"),
("stages/scienting-stages-default.json", "scienting-stages/1"),
],
)
def test_a_registry_file_is_read_by_its_path_under_registry(name, fmt):
assert resources.registry(name)["format"] == fmt
def test_the_rules_registry_lists_every_rule_by_id():
rules = resources.registry("rules.json")
assert "doc.suspect.witness" in json.dumps(rules)
@pytest.mark.parametrize(
"name",
["", "README.md", "../pyproject.toml", "stamps/../rules.json", "/rules.json"],
)
def test_a_registry_name_that_is_not_a_plain_json_path_is_refused(name):
with pytest.raises(ValueError, match="no registry file"):
resources.registry(name)
def test_a_missing_registry_file_is_an_error(layout):
(layout / "registry").mkdir()
with pytest.raises(FileNotFoundError):
resources.registry("rules.json")