Credibility pass: comments state constraints, not development history

A skeptical-cloner review flagged the patterns that read as AI-iteration
residue: test comments and section headers narrating the review process
that produced them, "legacy format" framing in a days-old repo, shadow
re-imports appended without reading file headers, one genuine machine
leftover (FIXTURE_CACHE = FIXTURE_CACHE), and a few register slips.
Every history-narrating comment is rewritten as the timeless invariant
it was guarding, test sections are grouped by behavior, function-local
imports are hoisted, and the README loses its one marketing clause and
heaviest dash runs. No behavior changes; 176 tests unchanged and green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Eric Wagoner
2026-08-02 15:08:22 -04:00
parent 92aaa91a49
commit 10f65d8aba
14 changed files with 93 additions and 141 deletions
+14 -32
View File
@@ -16,6 +16,7 @@ from bggpipe.bgg_client import BGGClient
from bggpipe.config import Config
from bggpipe.resolve import read_matches, write_matches
from bggpipe.review import ReviewSession, run_review
from bggpipe.webreview import DismissStore
FIXTURES = Path(__file__).parent / "fixtures" / "bgg_cache"
@@ -291,12 +292,10 @@ def test_version_pass_is_skippable(tmp_path):
assert row["version_status"] == "version_ambiguous" # untouched, review later
# -- audit-fix regressions ----------------------------------------------
# -- concurrent-rewrite and degradation safety --------------------------
def test_veto_merge_persists_against_future_dedupe(tmp_path):
from bggpipe.resolve import read_matches
cfg = _setup(
tmp_path,
[
@@ -327,12 +326,10 @@ def test_failed_save_never_leaves_memory_ahead_of_disk(tmp_path, monkeypatch):
)
row = session.rows[0]
import bggpipe.review as review_mod
def exploding_write(path, rows):
raise OSError("disk full")
monkeypatch.setattr(review_mod, "write_matches", exploding_write)
monkeypatch.setattr("bggpipe.review.write_matches", exploding_write)
with pytest.raises(OSError):
session.decide_reject(row)
# memory was rolled back to what disk actually holds
@@ -341,8 +338,6 @@ def test_failed_save_never_leaves_memory_ahead_of_disk(tmp_path, monkeypatch):
def test_save_merges_own_decision_over_concurrent_external_rewrite(tmp_path):
from bggpipe.resolve import read_matches, write_matches
cfg = _setup(tmp_path, [_row(title_raw="Mystery", match_status="unmatched")])
session = ReviewSession(
cfg,
@@ -364,13 +359,10 @@ def test_save_merges_own_decision_over_concurrent_external_rewrite(tmp_path):
def test_manual_id_unknown_to_bgg_warns_instead_of_crashing(tmp_path):
# an empty /thing result (mistyped id) used to crash the whole session
import httpx as _httpx
empty_things = BGGClient(
cache_dir=tmp_path / "cache",
transport=_httpx.MockTransport(
lambda req: _httpx.Response(200, text='<items total="0"></items>')
transport=httpx.MockTransport(
lambda req: httpx.Response(200, text='<items total="0"></items>')
),
sleep=lambda s: None,
)
@@ -385,11 +377,9 @@ def test_manual_id_unknown_to_bgg_warns_instead_of_crashing(tmp_path):
def test_every_tui_decision_after_external_rewrite_is_saved(tmp_path):
# THE round-2 catch: the TUI iterates row references snapshotted before
# any reload; after decision 1 triggers a reload, decisions 2..N used
# to be counted but never written.
from bggpipe.resolve import read_matches, write_matches
# run() iterates row references snapshotted before any reload; every
# decision must be re-adopted into the current list or it would be
# counted but never written.
cfg = _setup(
tmp_path,
[
@@ -422,10 +412,8 @@ def test_every_tui_decision_after_external_rewrite_is_saved(tmp_path):
def test_fill_version_uses_the_approved_rows_own_cues(tmp_path):
# round-3 HIGH: two same-title entries are two EDITIONS; the title-only
# dict handed every row the LAST entry's cues, scoring the wrong version
import json as _json
# two same-title entries are two editions: the version lookup must use
# the row's own photo-keyed cues, never a title-keyed last-wins dict
entry_good = {
"title_raw": "Wingspan",
"publisher_hint": "Stonemaier", # matches the fixture's version
@@ -445,42 +433,36 @@ def test_fill_version_uses_the_approved_rows_own_cues(tmp_path):
title_raw="Wingspan",
match_status="ambiguous",
source_photos="good.jpg",
candidates_json=_json.dumps(
candidates_json=json.dumps(
[{"bgg_id": 266192, "name": "Wingspan", "year": 2019}]
),
)
],
)
(cfg.data_dir / "titles.json").write_text(_json.dumps([entry_good, entry_bad]))
(cfg.data_dir / "titles.json").write_text(json.dumps([entry_good, entry_bad]))
session = ReviewSession(
cfg, console=quiet_console(), input_fn=scripted(), client=fixture_client()
)
row = session.rows[0]
session.decide_pick(row, {"bgg_id": 266192, "name": "Wingspan", "year": 2019})
# with last-wins cues (entry_bad) this was version_unknown; the row's own
# photo (good.jpg) must select entry_good's cues and find the version
# the row's own photo (good.jpg) must select entry_good's cues
assert row["version_status"] == "version_auto"
assert row["version_id"] == "465063"
def test_dismiss_failure_keeps_ticket_visible(tmp_path, monkeypatch):
import bggpipe.webreview as webreview_mod
from bggpipe.webreview import DismissStore
store = DismissStore(tmp_path / "dismissed.json")
def exploding(path, text):
raise OSError("disk full")
monkeypatch.setattr(webreview_mod, "atomic_write_text", exploding)
monkeypatch.setattr("bggpipe.webreview.atomic_write_text", exploding)
with pytest.raises(OSError):
store.add("photo|loc|txt|art")
assert store.keys == set() # memory never claims what disk doesn't hold
def test_corrupt_dismiss_file_is_quarantined_not_fatal(tmp_path):
from bggpipe.webreview import DismissStore
path = tmp_path / "dismissed.json"
path.write_text('["torn')
with pytest.warns(UserWarning, match="unreadable"):