Skip to content

Commit b6a366a

Browse files
tmoostingclaude
andcommitted
doctor: read a supertype with the package's one fold
The doctor compared a supertype (the Charter's word in flags 8 and 11, Tenure and Membership in flag 2) with str.strip() and str.casefold(). Every other reader of a pair uses room._fold: Unicode White_Space trimmed, simple case folding. What changes: str.strip() also removes U+001C to U+001F, which are not White_Space, so a word ending in one of them was a charter to the doctor and not to is_charter_element. No letter changes: checked over every code point, no character whose full folding differs from its simple one folds into a piece of the three words. The new test fails on the old code. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1 parent 5998daf commit b6a366a

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ The package version runs on its own semver; the schema it is generated from is `
44

55
## Unreleased
66

7+
- `onlyworlds.doctor` reads a supertype (the Charter's word in flags 8 and 11, `Tenure` and `Membership` in flag 2) with the package's one fold, as `is_charter_element` and every profile reader do: Unicode White_Space trimmed, simple case folding. It used `str.strip()` and `str.casefold()`. What changes: a supertype with U+001C to U+001F at an end is no longer read as the word (`str.strip()` removes those four; they are not White_Space). No letter changes: checked over every code point, no character whose full folding differs from its simple one folds into a piece of the three words.
8+
79
## 0.128.1 (2026-11-15)
810

911
- **Schema repinned to schema-dist v0.34.1-dist.130** (from dist.129; canonical 00.34.01 unchanged, no schema file moved): the message profile says a body that is not a message answers false from the unseen-recipients reading whatever the key, and its fixture gains one case for it (`keyless-non-message-is-not-unseen`), which `has_unseen_recipients` already answered; the profile writes the keyless readers as the package takes them (`is_to_everyone(message, keyless=True)`). `has_unseen_recipients`' docstring says so.

‎src/onlyworlds/doctor.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,9 @@ def _type_order(element_type: str) -> int:
465465

466466

467467
def _folded(value: Any) -> str:
468-
return value.strip().casefold() if isinstance(value, str) else ""
468+
"""A supertype as the profile readers compare it (``room._fold``): Unicode White_Space trimmed, simple case
469+
folding. Never ``str.strip()`` (it also removes U+001C to U+001F) or ``str.casefold()`` (full folding)."""
470+
return _fold(value) if isinstance(value, str) else ""
469471

470472

471473
def fold_name(name: str) -> str:

‎tests/test_doctor.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,19 @@ def test_8_no_charter_is_a_finding_of_its_own() -> None:
693693
assert f["element"] is None and f["reason"].startswith("no charter")
694694

695695

696+
def test_8_reads_the_charter_word_as_the_profile_readers_do() -> None:
697+
# One fold in the package: the supertype is trimmed of Unicode White_Space and folded simply (room._fold), as
698+
# is_charter_element reads it. U+001F is not White_Space (str.strip() removes it), so a word ending in it is
699+
# not the charter's word; a no-break space and an em space are, at either end.
700+
def report(supertype: str) -> Report:
701+
elements = on_the_wire(edit(clean(), "law", LAW1, supertype=supertype))
702+
return api_report(FakeReader(elements, feed_of(elements)))
703+
704+
(f,) = found(report("Charter" + chr(0x1F)), "8")
705+
assert f["element"] is None and f["reason"].startswith("no charter")
706+
assert found(report(chr(0xA0) + "CHARTER" + chr(0x2003)), "8") == []
707+
708+
696709
def test_2_and_8_do_not_run_when_the_feed_cannot_be_read() -> None:
697710
r = api_report(FakeReader(on_the_wire(clean()), feed_fails=True))
698711
assert {x["flag"] for x in r.not_run} >= {"2", "8"}

0 commit comments

Comments
 (0)