- app/tx/reconcile.py called the payout retry "a future payout-retry routine — still an open gap". It shipped as B-26: clearing payout_txid leaves the round in exactly the state _retry_payout_if_due picks up, so an abandoned payout rebuilds itself and the log line next to it is an alert, not the recovery path. Reading it the old way, an operator would go hand-fix a round the scheduler was already retrying. - app/db/base.py sized the SQLite busy timeout against "five concurrent background tasks" and then listed only the non-listener ones; the lifespan starts six. - The third item (app/auth/routes.py citing B-31 where it meant B-33) was already correct in the tree; the test pins it so it stays that way. tests/unit/test_code_comments.py derives the task count from the lifespan's own create_task calls rather than restating it, so the comment fails the next time a task is added or removed instead of quietly going stale again. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
"""B-69: in-code comments that describe the rest of the system must stay true.
|
|
|
|
Three had rotted: the reconciler still called the payout retry "a future
|
|
payout-retry routine — still an open gap" long after B-26 shipped it,
|
|
app/db/base.py sized the SQLite busy timeout against "five" background tasks
|
|
when there are six, and app/auth/routes.py cited the wrong B-nn. A comment is
|
|
invisible to every other test in the suite, so the claims are pinned here.
|
|
"""
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
|
|
_ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def _read(relative: str) -> str:
|
|
return (_ROOT / relative).read_text(encoding="utf-8")
|
|
|
|
|
|
def test_background_task_count_in_the_busy_timeout_comment_is_right():
|
|
started = len(re.findall(r"asyncio\.create_task\(", _read("app/main.py")))
|
|
assert started == 6, "the lifespan's task count changed — update app/db/base.py's comment"
|
|
|
|
comment = _read("app/db/base.py").split("_SQLITE_BUSY_TIMEOUT_MS", 1)[0]
|
|
match = re.search(r"(\w+) concurrent background tasks", comment)
|
|
assert match, "app/db/base.py no longer explains what the busy timeout is sized for"
|
|
words = {"four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8}
|
|
assert words.get(match.group(1)) == started
|
|
|
|
|
|
def test_the_reconciler_does_not_call_the_payout_retry_an_open_gap():
|
|
source = _read("app/tx/reconcile.py")
|
|
assert "still an open gap" not in source
|
|
# It exists (B-26) and is what actually recovers an abandoned payout, so the
|
|
# comment must point at it rather than at an operator.
|
|
assert "B-26" in source
|
|
|
|
|
|
def test_the_payout_retry_the_comment_points_at_still_exists():
|
|
assert "_retry_payout_if_due" in _read("app/rounds/scheduler.py")
|
|
|
|
|
|
def test_the_login_throttle_comment_cites_its_own_finding():
|
|
limiters = _read("app/auth/routes.py").split("_rate_limiters", 1)[1][:1500]
|
|
assert "B-33" in limiters
|
|
assert "B-31" not in limiters # B-31 is the resubscribe fan-out, a different fix
|