Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .agents/skills/comment-and-doc-style/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,15 @@ silent pass, a letter of a recorded name excepted per the bullet below.
- **Tier 3, always legitimate.** Scientific and unit symbols whose ASCII form would be a lie:
micro (U+00B5), degree (U+00B0), ohm (U+2126), pi (U+03C0), superscript two and three (U+00B2,
U+00B3), section (U+00A7). Keep the symbol, never approximate it away or spell it out.
- **Tier 4, emoji callout markers.** Each is admitted alone or followed by VARIATION SELECTOR-16
(U+FE0F): warning (U+26A0), information (U+2139), check mark (U+2705), cross mark (U+274C), memo
as the note marker (U+1F4DD), and light bulb (U+1F4A1). The gate keeps reporting every other
emoji, and a U+FE0F not directly after a listed marker. A downstream repository needs no markup
to carry one, and an agent may write one only where it is mirroring a callout a developer typed.
- **Unicode a developer deliberately typed** stays regardless of tier, such as emoji used for
emphasis or as callout markers. Never strip a developer's own characters, this is developer
authored text and not a license for the agent to add its own.
emphasis. Never strip a developer's own characters, this is developer authored text and not a
license for the agent to add its own. Among emoji the gate admits only the tier-4 markers, so
another developer-typed emoji is classified here before it passes.
- **A letter in a recorded name keeps its actual spelling.** A person's or a place's name that a
document records as data is written with its own letters and the marks they carry, since
folding one to ASCII records a different name. Anywhere else a letter the agent writes that no
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d6793f184056ef85
ffd0a72a845531f3
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,15 @@ silent pass, a letter of a recorded name excepted per the bullet below.
- **Tier 3, always legitimate.** Scientific and unit symbols whose ASCII form would be a lie:
micro (U+00B5), degree (U+00B0), ohm (U+2126), pi (U+03C0), superscript two and three (U+00B2,
U+00B3), section (U+00A7). Keep the symbol, never approximate it away or spell it out.
- **Tier 4, emoji callout markers.** Each is admitted alone or followed by VARIATION SELECTOR-16
(U+FE0F): warning (U+26A0), information (U+2139), check mark (U+2705), cross mark (U+274C), memo
as the note marker (U+1F4DD), and light bulb (U+1F4A1). The gate keeps reporting every other
emoji, and a U+FE0F not directly after a listed marker. A downstream repository needs no markup
to carry one, and an agent may write one only where it is mirroring a callout a developer typed.
- **Unicode a developer deliberately typed** stays regardless of tier, such as emoji used for
emphasis or as callout markers. Never strip a developer's own characters, this is developer
authored text and not a license for the agent to add its own.
emphasis. Never strip a developer's own characters, this is developer authored text and not a
license for the agent to add its own. Among emoji the gate admits only the tier-4 markers, so
another developer-typed emoji is classified here before it passes.
- **A letter in a recorded name keeps its actual spelling.** A person's or a place's name that a
document records as data is written with its own letters and the marks they carry, since
folding one to ASCII records a different name. Anywhere else a letter the agent writes that no
Expand Down
26 changes: 21 additions & 5 deletions .github/actions/prose-gate/prose_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

markdownlint, cspell, actionlint, and editorconfig-checker all pass on prose that breaks
these rules, so nothing enforced them before this script. Rules implemented:
charset Non-ASCII judged against the three tiers the charset rule defines.
charset Non-ASCII judged against the tiers the charset rule defines, tier 4 being emoji markers.
charset-unknown Non-ASCII in no tier, bar a Latin letter and its U+0300-U+036F diacritics.
semicolon No semicolon in prose, outside a series or labeled pair carrying a comma.
dash No spaced hyphen joining or interrupting a sentence.
Expand Down Expand Up @@ -1087,10 +1087,16 @@ def discover(
}
)

# Tier 4 is a fixed set of emoji callout markers, each admitted alone or before VARIATION SELECTOR-16.
# They are warning, information, check mark, cross mark, memo (note), and light bulb.
# Every other emoji flags, and so does a selector not directly after one of these.
TIER4 = frozenset({"\u26a0", "\u2139", "\u2705", "\u274c", "\U0001f4dd", "\U0001f4a1"})
Comment thread
ptr727 marked this conversation as resolved.
Resolved
VARIATION_SELECTOR_16 = "\ufe0f"

CHARSET_CLASSIFY = (
"classify it in ptr727/ProjectTemplate:"
' the comment-and-doc-style skill\'s "Character set" section'
" and prose_lint.py's TIER1, TIER2, or TIER3 table"
" and prose_lint.py's TIER1, TIER2, TIER3, or TIER4 table"
)

COMBINING_DIACRITICS = frozenset(chr(c) for c in range(0x300, 0x370)) - {
Expand Down Expand Up @@ -2053,6 +2059,11 @@ def neighbor(step: int) -> str:
)


def starts_lowercase(text: str) -> bool:
"""Whether the text opens with a lowercase letter, a tier-4 marker being no letter."""
return text[:1].islower() and text[0] not in TIER4


def charset_findings(lineno: int, line: str) -> list[tuple[int, str, str]]:
"""Every non-ASCII character on the line, judged against its tier.

Expand All @@ -2065,10 +2076,15 @@ def charset_findings(lineno: int, line: str) -> list[tuple[int, str, str]]:
"""
out: list[tuple[int, str, str]] = []
carrier = False
marker = False
for pos, ch in enumerate(line):
after_marker, marker = marker, ch in TIER4
if ch.isascii():
carrier = ch.isalpha()
continue
if marker or (after_marker and ch == VARIATION_SELECTOR_16):
carrier = False
continue
name = unicodedata.name(ch, f"U+{ord(ch):04X}")
category = unicodedata.category(ch)
if (
Expand Down Expand Up @@ -2401,7 +2417,7 @@ def comment_wrap_findings(path: Path, raw: str, lines: list[str]) -> list[tuple[
and prev_body
and not SENT_END.search(prev_body)
and not SENT_END.search(prev_whole)
and body[:1].islower()
and starts_lowercase(body)
)
if continuation:
out.append(
Expand All @@ -2415,7 +2431,7 @@ def comment_wrap_findings(path: Path, raw: str, lines: list[str]) -> list[tuple[
# A label opening a definition is exempt, since the lowercase word is the name being defined.
elif (
leading
and body[:1].islower()
and starts_lowercase(body)
and not COMMENT_LABEL.match(body)
and not is_tool_directive(body)
):
Expand Down Expand Up @@ -3248,7 +3264,7 @@ def check_file(
p
and not SENT_END.search(p)
and not p.endswith((":", "-", "|"))
and stripped[0].islower()
and starts_lowercase(stripped)
):
out.append(
(
Expand Down
10 changes: 8 additions & 2 deletions .github/skills/comment-and-doc-style/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,15 @@ silent pass, a letter of a recorded name excepted per the bullet below.
- **Tier 3, always legitimate.** Scientific and unit symbols whose ASCII form would be a lie:
micro (U+00B5), degree (U+00B0), ohm (U+2126), pi (U+03C0), superscript two and three (U+00B2,
U+00B3), section (U+00A7). Keep the symbol, never approximate it away or spell it out.
- **Tier 4, emoji callout markers.** Each is admitted alone or followed by VARIATION SELECTOR-16
(U+FE0F): warning (U+26A0), information (U+2139), check mark (U+2705), cross mark (U+274C), memo
as the note marker (U+1F4DD), and light bulb (U+1F4A1). The gate keeps reporting every other
emoji, and a U+FE0F not directly after a listed marker. A downstream repository needs no markup
to carry one, and an agent may write one only where it is mirroring a callout a developer typed.
- **Unicode a developer deliberately typed** stays regardless of tier, such as emoji used for
emphasis or as callout markers. Never strip a developer's own characters, this is developer
authored text and not a license for the agent to add its own.
emphasis. Never strip a developer's own characters, this is developer authored text and not a
license for the agent to add its own. Among emoji the gate admits only the tier-4 markers, so
another developer-typed emoji is classified here before it passes.
- **A letter in a recorded name keeps its actual spelling.** A person's or a place's name that a
document records as data is written with its own letters and the marks they carry, since
folding one to ASCII records a different name. Anywhere else a letter the agent writes that no
Expand Down
4 changes: 2 additions & 2 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ Every Docker command has a timeout. The output identifies target counts, phase b

## `prose_lint.py`

Enforces the [`GOVERNANCE.md`][governance] "Documentation Style Conventions" rules that no linter checks: non-ASCII judged against the charset rule's three tiers, a semicolon in prose, a spaced hyphen joining or interrupting a sentence, a duplicated consecutive word, a British spelling, and the shape of a comment's prose. It carries one rule from elsewhere in that document, `home-path`, which comes from "Representative Data in Agent-Authored Text" and catches an absolute home path naming a real account. That rule closes the pattern-detectable sliver of its section and nothing beyond it, since the exposure the section exists for was name-shaped and no pattern finds a name. `OPERATIONS.md` is exempt because its runbooks carry the literal path an operator types.
Enforces the [`GOVERNANCE.md`][governance] "Documentation Style Conventions" rules that no linter checks: non-ASCII judged against the charset rule's tiers, a semicolon in prose, a spaced hyphen joining or interrupting a sentence, a duplicated consecutive word, a British spelling, and the shape of a comment's prose. It carries one rule from elsewhere in that document, `home-path`, which comes from "Representative Data in Agent-Authored Text" and catches an absolute home path naming a real account. That rule closes the pattern-detectable sliver of its section and nothing beyond it, since the exposure the section exists for was name-shaped and no pattern finds a name. `OPERATIONS.md` is exempt because its runbooks carry the literal path an operator types.

The tiers decide by context rather than by a flat ban. Tier 1 carries no meaning its ASCII form loses and always flags. Tier 2 is an operator, kept next to a figure or another operator and replaced between words, so a threshold table reads as the range it is. Tier 3 is a unit or scientific symbol whose ASCII form would be a lie and never flags. Developer-typed characters such as emoji are preserved regardless of tier, and an un-tiered one other than a Latin letter or a U+0300-U+036F diacritic it carries is still reported as `charset-unknown` until it is classified.
The tiers decide by context rather than by a flat ban. Tier 1 carries no meaning its ASCII form loses and always flags. Tier 2 is an operator, kept next to a figure or another operator and replaced between words, so a threshold table reads as the range it is. Tier 3 is a unit or scientific symbol whose ASCII form would be a lie and never flags. Tier 4 is a fixed set of emoji callout markers (warning, information, check mark, cross mark, memo, light bulb), each admitted alone or followed by VARIATION SELECTOR-16, and a U+FE0F anywhere else still flags. Developer-typed characters such as other emoji are preserved by the rule but not admitted by the gate, and an un-tiered one other than a Latin letter or a U+0300-U+036F diacritic it carries is still reported as `charset-unknown` until it is classified.

A character in no tier is a `charset-unknown` finding rather than a silent pass, since a gate that allows whatever it does not recognize stops gating as the character set grows. A Latin letter, with any diacritic from the U+0300-U+036F combining block that it carries, is the exception and never flags, since it may spell a recorded name, which the charset rule says keeps its actual spelling, and nothing tells a name from a word by its characters. A letter of another script, a compatibility form such as a ligature, any other mark, and a diacritic standing alone still flag, so the gate covers the Latin part of that rule and nothing wider. Classifying one is a fleet-law edit, so the whole-tree step that reports the backlog is warn-only, while the pull request gate blocks on one the change itself introduces. Which letters count as Latin follows the Unicode data of the Python running the gate, so a letter newer than that data is still reported.

Expand Down
92 changes: 91 additions & 1 deletion tests/test_prose_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def test_an_unclassified_character_names_where_to_classify_it(self) -> None:
[(_, kind, message)] = prose_lint.check_file(path, {"charset-unknown"})
self.assertEqual("charset-unknown", kind)
self.assertIn('the comment-and-doc-style skill\'s "Character set" section', message)
self.assertIn("prose_lint.py's TIER1, TIER2, or TIER3 table", message)
self.assertIn("prose_lint.py's TIER1, TIER2, TIER3, or TIER4 table", message)
self.assertIn("classify it in ptr727/ProjectTemplate:", message)
self.assertNotIn("GOVERNANCE.md", message)

Expand All @@ -246,6 +246,85 @@ def test_a_latin_named_symbol_is_still_reported(self) -> None:
self.kinds("a \u271d here\n", {"charset", "charset-unknown"}),
)

def test_a_callout_marker_is_admitted_alone_or_with_variation_selector_16(self) -> None:
"""Tier 4 admits the documented emoji markers, each bare or followed by VARIATION SELECTOR-16."""
rules = {"charset", "charset-unknown"}
documented = {0x26A0, 0x2139, 0x2705, 0x274C, 0x1F4DD, 0x1F4A1}
self.assertEqual(documented, {ord(ch) for ch in prose_lint.TIER4})
Comment thread
ptr727 marked this conversation as resolved.
Resolved
for ch in prose_lint.TIER4:
with self.subTest(codepoint=f"U+{ord(ch):04X}"):
self.assertEqual([], self.kinds(f"> {ch} **Note:** text\n", rules))
self.assertEqual([], self.kinds(f"> {ch}\ufe0f **Note:** text\n", rules))

def test_the_reported_warning_pair_is_admitted(self) -> None:
"""The pair that rendered as a finding in the original report now passes."""
line = "> \u26a0\ufe0f **Warning:** Example callout.\n"
self.assertEqual([], self.kinds(line, {"charset", "charset-unknown"}))

def test_a_non_callout_emoji_is_still_reported_even_with_variation_selector_16(self) -> None:
"""Only the fixed set is admitted, so any other emoji flags, selector or not."""
rules = {"charset", "charset-unknown"}
for ch in ("\U0001f680", "\u2764", "\u2728", "\u2603"):
with self.subTest(codepoint=f"U+{ord(ch):04X}"):
self.assertNotIn(ch, prose_lint.TIER4)
self.assertEqual(["charset-unknown"], self.kinds(f"a {ch} here\n", rules))
self.assertEqual(
["charset-unknown", "charset-unknown"],
self.kinds(f"a {ch}\ufe0f here\n", rules),
)

def test_a_marker_opening_a_comment_or_line_is_not_a_lowercase_letter(self) -> None:
"""U+2139 is category Ll, yet a marker opening a comment is no lowercase sentence start."""
info = chr(0x2139)
self.assertTrue(info.islower())
self.assertFalse(prose_lint.starts_lowercase(f"{info}\ufe0f Run setup first."))
self.assertTrue(prose_lint.starts_lowercase("run setup first."))

def test_a_marker_opening_a_line_is_no_continuation_or_lowercase_start(self) -> None:
"""Each caller of the lowercase test treats a marker as a sentence start, end to end."""
info = chr(0x2139)
comment_rules = {"comment-wrap", "comment-case"}
for opener in (info, f"{info}\ufe0f"):
with self.subTest(opener=opener):
self.assertEqual(
[],
self.kinds(
f"# A sentence that keeps\n# {opener} Run setup first.\n",
comment_rules,
"bait.py",
),
)
self.assertEqual(
[], self.kinds(f"# {opener} Run setup first.\n", comment_rules, "bait.py")
)
self.assertEqual(
[],
self.kinds(
f"A sentence that keeps\n{opener} Run setup first.\n", {"sentence-split"}
),
)
self.assertEqual(
["comment-wrap"],
self.kinds("# A sentence that keeps\n# going on.\n", comment_rules, "bait.py"),
)
self.assertEqual(
["sentence-split"],
self.kinds("A sentence that keeps\ngoing on.\n", {"sentence-split"}),
)

def test_a_stray_variation_selector_16_is_still_reported(self) -> None:
"""The selector is admitted only directly after a marker, never alone or after a gap."""
rules = {"charset", "charset-unknown"}
marker = chr(0x26A0)
for text in (
"stray \ufe0f here",
f"{marker} \ufe0f here",
f"{marker}\ufe0f\ufe0f here",
"\ufe0f" + marker + " here",
):
with self.subTest(text=text):
self.assertEqual(["charset-unknown"], self.kinds(f"{text}\n", rules))

def test_a_mark_that_spells_no_name_is_still_reported(self) -> None:
"""A mark that is no diacritic, or that no Latin letter carries, is reported, not passed."""
rules = {"charset", "charset-unknown"}
Expand Down Expand Up @@ -364,11 +443,22 @@ def test_tier_three_is_allowed_rather_than_replaced(self) -> None:
self.assertNotIn(chr(cp), prose_lint.TIER1)
self.assertNotIn(chr(cp), prose_lint.TIER2)

def test_tier_four_markers_are_exactly_the_skill_text(self) -> None:
"""The markers the rule text names, less the selector it admits, are the gate's set."""
m = re.search(r"^- \*\*Tier 4,(.*?)(?=^- \*\*)", self.section, re.MULTILINE | re.DOTALL)
if m is None:
self.fail("the Tier 4 bullet moved, so the parse is blind")
named = {int(h, 16) for h in re.findall(r"U\+([0-9A-Fa-f]{4,6})\b", m.group(1))}
named.discard(ord(prose_lint.VARIATION_SELECTOR_16))
self.assertEqual(named, {ord(ch) for ch in prose_lint.TIER4})

def test_the_tiers_do_not_overlap(self) -> None:
t1, t2, t3 = set(prose_lint.TIER1), set(prose_lint.TIER2), set(prose_lint.TIER3)
t4 = set(prose_lint.TIER4)
self.assertEqual(set(), t1 & t2)
self.assertEqual(set(), t1 & t3)
self.assertEqual(set(), t2 & t3)
self.assertEqual(set(), t4 & (t1 | t2 | t3))


class TestDupword(BaitCase):
Expand Down
Loading