From 9db36877526ef0a7a7be90563d515b4d72ddcd65 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 30 Aug 2026 22:12:09 +0200 Subject: [PATCH] =?UTF-8?q?release:=200.1.7=20=C2=ABCallistus=20I=C2=BB=20?= =?UTF-8?q?=E2=80=94=20a=20version=20now=20says=20which=20pope,=20and=20wh?= =?UTF-8?q?en?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "Wersja 0.1.7 «Callistus I»" told nobody whether Callistus was the fifteenth pope or the hundredth, and the changelog was the one place the ladder is actually read. pope_line() derives both facts from popes.json -- the ordinal, and the `reign` string exactly as the table spells it, so the one reigning pope keeps his single year instead of being padded into a range he never had. It appears in all four places a version is named: the group announcement (header and every block of a backlog), each section of DOCS-changelog.md, /healthz, and the !papiez caption, which now describes the release's pope in the same sentence it uses for every other one. The changelog's copy is checked rather than trusted, like the heading name already was: a test walks the raw file and compares each line against popes.json, so a hand-edited ordinal fails here instead of in a group. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_017w1HZ3cZ7neL3rFdQ6VMBA --- DOCS-changelog.md | 39 +++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- signal_bot/announce.py | 5 +++-- signal_bot/app.py | 10 +++++++-- signal_bot/popes_command.py | 4 ++-- signal_bot/versioning.py | 14 ++++++++++++- tests/test_announce_render.py | 8 +++++++ tests/test_changelog.py | 30 ++++++++++++++++++++++++++- tests/test_healthz.py | 4 +++- tests/test_popes_command.py | 5 +++-- tests/test_versioning.py | 10 +++++++++ 11 files changed, 119 insertions(+), 12 deletions(-) diff --git a/DOCS-changelog.md b/DOCS-changelog.md index aea93c7..6bc2fd5 100644 --- a/DOCS-changelog.md +++ b/DOCS-changelog.md @@ -71,8 +71,19 @@ this repo: describe what changes for them. 0.0.1 shipped a bullet about `/healthz`, an endpoint bound to 127.0.0.1 that nobody in a Signal group can reach, and it was rightly called out. +## 0.1.7 — Callistus I + +papież nr 16 z 267, pontyfikat 217-222 + +- każda wersja mówi teraz, którym z kolei papieżem jest jej patron i w jakich + latach panował — w ogłoszeniu nowej wersji, w changelogu i przy `!papież` +- `!papież` pisze to samo zdaniem, którym opisuje każdego innego papieża, więc + nie trzeba już zgadywać, czy «Callistus I» to ten piętnasty, czy szesnasty + ## 0.1.6 — Zephyrinus +papież nr 15 z 267, pontyfikat 199-217 + - statystyki o 21:37 są od teraz o **dzisiejszym** dniu, a nie o wczorajszym — wieczorny post pokazuje wreszcie ten dzień, który właśnie mijał - licznik zamyka się o 21:37, więc to, co napiszecie później, wpada do jutra; @@ -82,6 +93,8 @@ reach, and it was rightly called out. ## 0.1.5 — Victor I +papież nr 14 z 267, pontyfikat 189-199 + - ogłoszenie nowej wersji przychodzi teraz ze zdjęciem papieża, po którym ta wersja się nazywa, i z linkiem do jego strony na polskiej Wikipedii — dokładnie tak, jak robi to `!papież` @@ -90,11 +103,15 @@ reach, and it was rightly called out. ## 0.1.4 — Eleutherius +papież nr 13 z 267, pontyfikat 175-189 + - `!pomoc` (albo `!help`) wypisuje wszystkie komendy i mówi jednym zdaniem, co każda robi — do tej pory nigdzie na czacie nie było ich listy ## 0.1.3 — Soterius +papież nr 12 z 267, pontyfikat 166-175 + - "POCZEKAJ 1 SEKUND" odmienia się wreszcie po polsku — teraz jest 1 SEKUNDĘ, 2 SEKUNDY, 5 SEKUND - odczekanie tego, co bot każe, wreszcie działa: dotąd każda nieudana próba @@ -103,12 +120,16 @@ reach, and it was rightly called out. ## 0.1.2 — Anicetus +papież nr 11 z 267, pontyfikat 155-166 + - `!ja` pokazywał wszystkim tę samą godzinę (12:00) — to był artefakt danych sprzed przebudowy licznika, a nie wasze zwyczaje. Teraz pokazuje prawdziwe godziny, a komu ich nie znamy, temu nie zmyśla ## 0.1.1 — Pius I +papież nr 10 z 267, pontyfikat 140-155 + - komendy mówią teraz, co pokazują — `!korona` na pustych danych tłumaczy, co się w niej pojawi, zamiast samego "za mało danych" - `!ja` pisze "między 12:00 a 13:00" zamiast "o 12:00" — bo to godzina, a @@ -116,6 +137,8 @@ reach, and it was rightly called out. ## 0.1.0 — Hyginus +papież nr 9 z 267, pontyfikat 136-140 + - podsumowanie liczy teraz zdjęcia i filmy — zdjęcie bez podpisu było wcześniej warte zero, więc liczby wszystkim podskoczyły - kto nic nie napisał, pojawia się z zerem @@ -126,6 +149,8 @@ reach, and it was rightly called out. ## 0.0.7 — Telesphorus +papież nr 8 z 267, pontyfikat 125-136 + - nowa komenda `!papież` (działa też jako `!papiez`, `!papa`, `!pope`) — bot wrzuca losowego papieża: zdjęcie, imię po łacinie, lata pontyfikatu i link do polskiej Wikipedii. Do wyboru jest cała lista, 267 papieży od Świętego @@ -133,37 +158,51 @@ reach, and it was rightly called out. ## 0.0.6 — Xystus I +papież nr 7 z 267, pontyfikat 115-125 + - po restarcie komputera bot wraca sam — wcześniej, jeśli włączył się zanim Signal był gotowy, poddawał się po 25 sekundach i milczał do końca dnia; 30 sierpnia stało się to na osiem godzin ## 0.0.5 — Alexander I +papież nr 6 z 267, pontyfikat 105-115 + - komendy działają teraz niezależnie od tego, na jakiej klawiaturze je piszesz — `!gekon` napisany rosyjskimi literami (albo jako `!g3ck0`) wreszcie odpowiada, wcześniej bot go po prostu ignorował ## 0.0.4 — Evaristus +papież nr 5 z 267, pontyfikat 97-105 + - `!gekon` pokazuje teraz za każdym razem innego gekona — wcześniej wrzucał w kółko to samo zdjęcie ## 0.0.3 — Clemens I +papież nr 4 z 267, pontyfikat 88-97 + - nowa komenda `!gekon` — bot wrzuca losowe zdjęcie gekona; działa też `!gecko`, `!geckon`, `!geko`, `!gekony` i `!geckos` ## 0.0.2 — Anacletus +papież nr 3 z 267, pontyfikat 76-88 + - bot odpowiada teraz na konkretną wiadomość, cytując ją — w ruchliwej rozmowie widać, czyje `!cat` to jest ## 0.0.1 — Linus +papież nr 2 z 267, pontyfikat 64-76 + - wersje bota nazywają się teraz imionami kolejnych papieży - po aktualizacji bot ogłasza w grupie nową wersję i listę zmian - `/healthz` pokazuje wersję i papieża, więc widać co naprawdę działa ## 0.0.0 — Petrus +papież nr 1 z 267, pontyfikat 33-64 + - bot taki, jaki był przed drabinką papieską: `!cat`, `!dog` i dzienne podsumowanie diff --git a/pyproject.toml b/pyproject.toml index 5c7d7fb..c6033ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "signal-bot" -version = "0.1.6" +version = "0.1.7" description = "A Signal group bot: image commands and daily message tallies." readme = "README.md" license = "MIT" diff --git a/signal_bot/announce.py b/signal_bot/announce.py index f5c657d..057074c 100644 --- a/signal_bot/announce.py +++ b/signal_bot/announce.py @@ -29,7 +29,7 @@ import logging from typing import TYPE_CHECKING, Final from signal_bot.changelog import since -from signal_bot.versioning import article_url, latin_name, version_for +from signal_bot.versioning import article_url, latin_name, pope_line, version_for if TYPE_CHECKING: from collections.abc import Iterable @@ -58,7 +58,7 @@ def render(pope: Pope, releases: Iterable[Release]) -> str: """ shown = list(releases) header = f"Wersja {version_for(pope.ordinal)} \u00ab{latin_name(pope)}\u00bb wydana" - header = f"{header}\n{article_url(pope)}" + header = f"{header}\n{pope_line(pope)}\n{article_url(pope)}" omitted = max(0, len(shown) - MAX_RELEASES) shown = shown[-MAX_RELEASES:] if len(shown) == 1: @@ -68,6 +68,7 @@ def render(pope: Pope, releases: Iterable[Release]) -> str: "\n".join( [ f"{release.version} \u00ab{latin_name(release.pope_entry)}\u00bb", + pope_line(release.pope_entry), *(f"- {x}" for x in release.lines), ] ) diff --git a/signal_bot/app.py b/signal_bot/app.py index 8cd99a5..5320fb2 100644 --- a/signal_bot/app.py +++ b/signal_bot/app.py @@ -23,7 +23,7 @@ from signal_bot.selftest import SelfTestError from signal_bot.selftest import run as run_selftest from signal_bot.startup_retry import Starter from signal_bot.store import Store -from signal_bot.versioning import POPE, __version__, latin_name +from signal_bot.versioning import POPE, __version__, latin_name, pope_line if TYPE_CHECKING: from collections.abc import AsyncIterator @@ -94,7 +94,13 @@ async def healthz(response: Response) -> dict[str, str]: like, and is not the same thing as one that has gone deaf. """ starter: Starter = app.state.starter - build = {"version": __version__, "pope": latin_name(POPE)} + build = { + "version": __version__, + "pope": latin_name(POPE), + # The same sentence the group is shown, so "which release is this?" + # has one answer whether it is asked here or in Signal. + "papacy": pope_line(POPE), + } runtime = starter.runtime if runtime is None: response.status_code = status.HTTP_503_SERVICE_UNAVAILABLE diff --git a/signal_bot/popes_command.py b/signal_bot/popes_command.py index 02a4ff6..a9be5e5 100644 --- a/signal_bot/popes_command.py +++ b/signal_bot/popes_command.py @@ -11,7 +11,7 @@ import secrets from typing import TYPE_CHECKING, Final from signal_bot.animals import load_aliases -from signal_bot.versioning import POPES, article_url +from signal_bot.versioning import POPES, article_url, pope_line if TYPE_CHECKING: from signal_bot.decorators import Decorator @@ -35,7 +35,7 @@ def random_pope() -> Pope: def caption_for(pope: Pope) -> str: """Return the message that rides along with the portrait.""" - return f"{pope.ordinal}. {pope.name} — {pope.latin} ({pope.reign})\n{article_url(pope)}" + return f"{pope.name} — {pope.latin}\n{pope_line(pope)}\n{article_url(pope)}" def pope_handler(cache: PortraitCache) -> Handler: diff --git a/signal_bot/versioning.py b/signal_bot/versioning.py index 4244498..794c2a0 100644 --- a/signal_bot/versioning.py +++ b/signal_bot/versioning.py @@ -30,7 +30,7 @@ PATCHES_PER_MINOR: Final = 8 # Which release this build is. Bump by one per release; everything else, # including the version string in pyproject.toml, follows from it. -RELEASE_ORDINAL: Final = 15 +RELEASE_ORDINAL: Final = 16 _POPES_FILE: Final = Path(__file__).with_name("popes.json") @@ -183,6 +183,18 @@ def latin_name(pope: Pope) -> str: return f"{stem} {numeral}" if numeral else stem +def pope_line(pope: Pope) -> str: + """Where a release's pope sits in the list, and when he reigned. + + Derived from popes.json on both counts -- the ordinal, and the `reign` + string exactly as the table spells it, which is why a single-year + pontificate reads "pontyfikat 2025" rather than being padded into a + range it never had. Typing either by hand is how a changelog ends up + claiming a pope reigned in the wrong century. + """ + return f"papież nr {pope.ordinal} z {len(POPES)}, pontyfikat {pope.reign}" + + def article_url(pope: Pope) -> str: """Return the pl.wikipedia URL for a pope. diff --git a/tests/test_announce_render.py b/tests/test_announce_render.py index a233b4a..7004d58 100644 --- a/tests/test_announce_render.py +++ b/tests/test_announce_render.py @@ -26,6 +26,7 @@ def test_a_single_release_is_rendered_flat() -> None: message = render(LINUS, RELEASES[1:]) assert message == ( "Wersja 0.0.1 «Linus» wydana\n" + "papież nr 2 z 267, pontyfikat 64-76\n" "https://pl.wikipedia.org/wiki/Linus_%28papie%C5%BC%29\n" "Changelog:\n- druga zmiana" ) @@ -76,3 +77,10 @@ def test_render_names_the_version_and_lists_every_pending_line() -> None: def test_render_links_the_polish_article() -> None: """The same article !papież posts, built from the disambiguated title.""" assert "https://pl.wikipedia.org/wiki/Piotr_Aposto%C5%82" in render(PETRUS, RELEASES) + + +def test_every_block_of_a_backlog_names_its_own_pope() -> None: + """Two releases, two papacies -- the header's is not the whole ladder.""" + message = render(LINUS, RELEASES) + assert "papież nr 1 z 267, pontyfikat 33-64" in message + assert "papież nr 2 z 267, pontyfikat 64-76" in message diff --git a/tests/test_changelog.py b/tests/test_changelog.py index 83056ad..74cd66e 100644 --- a/tests/test_changelog.py +++ b/tests/test_changelog.py @@ -3,10 +3,19 @@ from __future__ import annotations +import re from pathlib import Path from signal_bot.changelog import Release, load, parse, since -from signal_bot.versioning import __version__, latin_name +from signal_bot.versioning import ( + __version__, + latin_name, + ordinal_for, + pope_for, + pope_line, +) + +HEADING = re.compile(r"^##\s+(\d+\.\d+\.\d+)\s*—") DOCUMENT = """\ # Changelog @@ -77,3 +86,22 @@ def test_every_heading_name_matches_the_derived_latin_one() -> None: """The doc is checked, not trusted: a typo here fails here, not in a group.""" for release in load(): assert release.pope == latin_name(release.pope_entry), release.version + + +def test_every_section_carries_its_derived_papacy_line() -> None: + """The ordinal and the reign are data, so the document may not disagree. + + Read off the raw file rather than the parsed releases: the parser ignores + anything that is not a heading or a bullet, which is what makes this line + free to add -- and what would let it rot unnoticed without this test. + """ + lines = Path("DOCS-changelog.md").read_text(encoding="utf-8").splitlines() + checked = 0 + for index, line in enumerate(lines): + heading = HEADING.match(line) + if heading is None: + continue + pope = pope_for(ordinal_for(heading.group(1))) + assert lines[index + 2] == pope_line(pope), heading.group(1) + checked += 1 + assert checked == len(load()) diff --git a/tests/test_healthz.py b/tests/test_healthz.py index 30da2f2..61e77f5 100644 --- a/tests/test_healthz.py +++ b/tests/test_healthz.py @@ -13,7 +13,7 @@ from fastapi import Response from signal_bot import app as app_module from signal_bot.app import healthz from signal_bot.liveness import Liveness -from signal_bot.versioning import POPE, __version__, latin_name +from signal_bot.versioning import POPE, __version__, latin_name, pope_line if TYPE_CHECKING: from signal_bot.config import Config @@ -73,6 +73,7 @@ async def test_healthz_names_the_build_either_way(config: Config) -> None: healthy = await healthz(Response()) assert healthy["version"] == __version__ assert healthy["pope"] == latin_name(POPE) + assert healthy["papacy"] == pope_line(POPE) deaf_gate = _gate(replace(config, silence_seconds=0), httpx.Response(400, json=DEAD_BODY)) for _ in range(3): @@ -81,3 +82,4 @@ async def test_healthz_names_the_build_either_way(config: Config) -> None: deaf = await healthz(Response()) assert deaf["version"] == __version__ assert deaf["pope"] == latin_name(POPE) + assert deaf["papacy"] == pope_line(POPE) diff --git a/tests/test_popes_command.py b/tests/test_popes_command.py index 44d8b08..d6c353e 100644 --- a/tests/test_popes_command.py +++ b/tests/test_popes_command.py @@ -94,7 +94,7 @@ async def test_it_posts_a_portrait_with_the_caption_attached( assert base64.b64decode(sent.image_base64) == IMAGE # One message, not two: the caption rides in the same payload. assert len(transport.sent) == 1 - assert sent.caption.startswith(tuple(str(p.ordinal) for p in POPES)) + assert "papież nr " in sent.caption assert "https://pl.wikipedia.org/wiki/" in sent.caption @@ -119,7 +119,8 @@ def test_the_caption_names_the_pope_in_both_languages() -> None: pope = POPES[263] assert pope.name == "Jan Paweł II" assert caption_for(pope) == ( - "264. Jan Paweł II — Ioannes Paulus Secundus (1978-2005)\n" + "Jan Paweł II — Ioannes Paulus Secundus\n" + "papież nr 264 z 267, pontyfikat 1978-2005\n" "https://pl.wikipedia.org/wiki/Jan_Pawe%C5%82_II" ) diff --git a/tests/test_versioning.py b/tests/test_versioning.py index da0c697..df76797 100644 --- a/tests/test_versioning.py +++ b/tests/test_versioning.py @@ -21,6 +21,7 @@ from signal_bot.versioning import ( latin_stem, ordinal_for, pope_for, + pope_line, roman_numeral, version_for, ) @@ -182,3 +183,12 @@ def test_the_article_url_uses_the_disambiguated_title() -> None: """name would 404 for the 72 popes who live at " (papież)".""" assert article_url(pope_for(13)).endswith("Eleuteriusz_%28papie%C5%BC%29") assert article_url(pope_for(264)).endswith("Jan_Pawe%C5%82_II") + + +def test_the_papacy_line_counts_from_the_table_not_a_constant() -> None: + assert pope_line(pope_for(15)) == "papież nr 15 z 267, pontyfikat 199-217" + + +def test_a_reigning_pope_keeps_his_open_ended_year() -> None: + """The last entry has one year, not a range; padding it would invent data.""" + assert pope_line(pope_for(267)).endswith("pontyfikat 2025")