refactor: drop the private aliases kept for the siblings

package._canonical_bytes, package._zip_entries, anchors._follow and
traces._anchors are gone; paperdesk and paperforms use the public names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YCVvg4F3wpYQjq1NQUSmxN
This commit is contained in:
alexmandClaude committed 2026-10-21 03:02:01 -04:00
1 parent 7c0f837713
commit f262337eac
6 files changed
+5 -22

No files matched your search

+1
View File
@@ -172,3 +172,4 @@ It is a minor change in the sense of [spec/00](spec/00-introduction.md): new rul
- Public names, with the old private names kept as aliases: `package.parse_canonical`, `parse_json`, `parse_jsonl`, `check_zip_entries` and `read_zip_files`; `tree.flatten` and `establish_with_side`, which keeps a producer's private keys; `hashing.strict_runs`; and `corrections.OPS` and `EMEND_KINDS` (`test_public_api.py`).
Also `anchors.follow` and `resolve_address`, `claims.parse_ref`, `parse_pin`, `format_ref` and `format_pin`, `layers.annotation_id`, `anchors_of` and the lists of body kinds, categories, verdicts and statuses, and `db.load_layer`, `read_state`, `delete` and `upgrade` (`test_anchors.py`, `test_claims.py`, `test_layers.py`, `test_db.py`).
- `text.collapse_ws`, `trim`, `remove_ws` and `digits` and `hashing.lossy_from_strict` are rewritten for speed, so a correction goes through the gate about three times faster, and are tested equal to the old code on every code point (`test_text.py`, `test_hashing.py`).
- The private aliases kept for the siblings are gone, now that paperdesk and paperforms use the public names: `package._canonical_bytes`, `package._zip_entries`, `anchors._follow` and `traces._anchors` (`tests/test_public_api.py::test_parse_canonical_reads_doubles_and_refuses_what_is_not_canonical`, `::test_check_zip_entries_returns_the_folder_without_reading`, `tests/test_anchors.py::TestFollow::test_follow_has_no_alias_under_its_old_private_name`).
-4
View File
@@ -245,10 +245,6 @@ def follow(state: State, nid: str) -> tuple[str | None, list[str], str | None]:
return _walk({n["id"] for n in state.nodes}, state.ids, nid)
# paperdesk's cite.py uses the old private name until it moves to `follow`.
_follow = follow
def resolve_address(
nodes: Iterable[Record],
ids: Iterable[Record],
-10
View File
@@ -169,11 +169,6 @@ def parse_canonical(data: bytes, where: str) -> Any:
return rec
# paperdesk's reader (reading.py) calls the old private name; it goes once paperdesk uses
# parse_canonical, parse_json or parse_jsonl.
_canonical_bytes = parse_canonical
def parse_jsonl(data: bytes, where: str) -> list[Record]:
"""Parse the bytes of a canonical JSONL file, one JSON value per line (spec/01 §1.9).
@@ -1218,11 +1213,6 @@ def check_zip_entries(zf: zipfile.ZipFile, limit: int = ZIP_LIMIT) -> str:
return folder
# paperdesk's reader (reading.py) calls the old private name; it goes once paperdesk uses
# check_zip_entries or read_zip_files.
_zip_entries = check_zip_entries
def _open_zip(path: StrPath) -> zipfile.ZipFile:
try:
return zipfile.ZipFile(path)
-4
View File
@@ -39,10 +39,6 @@ def doc_tag(store: str, key: str) -> str:
return f"tag:scient.ing,2026:doc:{store}/{key}"
# paperdesk's tracing.py uses the private name until it moves to layers.anchors_of.
_anchors = layers.anchors_of
def _bare(doc: str) -> str:
"""A document key without its store.
+2 -2
View File
@@ -836,8 +836,8 @@ def _jsonl(name):
class TestFollow:
def test_follow_is_the_old_private_name(self):
assert anchors._follow is anchors.follow
def test_follow_has_no_alias_under_its_old_private_name(self):
assert not hasattr(anchors, "_follow")
def test_a_live_node_is_followed_to_itself(self, tree):
assert anchors.follow(tree["state"], tree["s1"]) == (tree["s1"], [], None)
+2 -2
View File
@@ -19,7 +19,7 @@ from paperspec.tree import Refusal
def test_parse_canonical_reads_doubles_and_refuses_what_is_not_canonical():
value = package.parse_canonical(b'{"a":100000000000000000000}', "x")
assert value == {"a": 1e20} and isinstance(value["a"], float)
assert package._canonical_bytes is package.parse_canonical
assert not hasattr(package, "_canonical_bytes") # no alias for the old name
with pytest.raises(Refusal) as e:
package.parse_canonical(b'{ "a":1}', "x:1")
assert e.value.rule == "package.file.canonical"
@@ -68,7 +68,7 @@ def test_read_zip_files_refuses_what_is_not_a_zip(tmp_path):
def test_check_zip_entries_returns_the_folder_without_reading():
with zipfile.ZipFile(TINY_ZIP) as zf:
assert package.check_zip_entries(zf) == TINY.name
assert package._zip_entries is package.check_zip_entries
assert not hasattr(package, "_zip_entries") # no alias for the old name
def test_flatten_keeps_private_keys_and_leaves_the_spec_alone():