From 58addc62e55326be01b6124c5b649e2ed55034ae Mon Sep 17 00:00:00 2001 From: Ben Westgate Date: Wed, 7 Oct 2026 03:35:02 +0000 Subject: [PATCH] correct: Redact worksheet correction addends WorksheetCorrection had the same repr leak as CorrectionEdit: for an erasure the worksheet filled with q, the addend is the recovered character itself, and for any other position it is the true character XOR the written one. Leave addend out of the generated repr; field access, equality and the CLI's explicit display are unchanged. Tighten the regression to compare exact reprs and to check that the repaired payload text does not appear. Refs #129 Claude-Session: https://claude.ai/code/session_01T233rKgZqE5wzDm3EVTHL1 --- src/codex32/correction.py | 3 ++- tests/test_public_api.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/codex32/correction.py b/src/codex32/correction.py index 5df1a1c..1d4999e 100644 --- a/src/codex32/correction.py +++ b/src/codex32/correction.py @@ -55,7 +55,8 @@ @dataclass(frozen=True, slots=True) class WorksheetCorrection: reverse_index: int - addend: str + # An addend for a q-filled erasure is the recovered character itself. + addend: str = field(repr=False) @dataclass(frozen=True, slots=True, init=False) diff --git a/tests/test_public_api.py b/tests/test_public_api.py index 1901802..70106c5 100644 --- a/tests/test_public_api.py +++ b/tests/test_public_api.py @@ -19,6 +19,7 @@ Profile, Share, correct, + correct_worksheet_residue, parse_codex32, ) from codex32.errors import InvalidIdentifier, InvalidShareIndex, InvalidThreshold @@ -110,8 +111,11 @@ def test_correction_edits_do_not_render_recovery_characters() -> None: rendered = repr(candidate) assert len(candidate.edits) == 8 + assert text[9:17].lower() not in rendered.lower() assert all(f"'{edit.replacement}'" not in rendered for edit in candidate.edits) - assert "observed" not in rendered and "replacement" not in rendered + first = candidate.edits[0] + assert repr(first) == f"CorrectionEdit(kind='erasure', reverse_index={first.reverse_index})" + assert repr(correct_worksheet_residue("2ppjkw73qdjvc")) == "(WorksheetCorrection(reverse_index=37),)" def test_master_seed_default_rendering_does_not_disclose_seed_material() -> None: