Skip to content

fix: repair mojibake corruption; restore RUF001/002/003 tripwire - #8

Merged
mthamil107 merged 1 commit into
mainfrom
fix/mojibake-corruption
Aug 13, 2026
Merged

fix: repair mojibake corruption; restore RUF001/002/003 tripwire#8
mthamil107 merged 1 commit into
mainfrom
fix/mojibake-corruption

Conversation

@mthamil107

Copy link
Copy Markdown
Owner

The bug I introduced, and the real bug it hid

The earlier CI-green PR ignored RUF001/002/003 as "intentional typography." That was wrong — those rules were correctly flagging mojibake (UTF-8 decoded as cp1252 and saved back). Two of the corrupted spots are user-facing in cli.py:

  • src/memorywire/cli.py:55 — the --help description (— memorywire CLI), printed on every memorywire --help.
  • src/memorywire/cli.py:262 — the recall-output truncation marker ().

On a native Windows console the corrupted byte can't be encoded, the capture thread dies, and memorywire --help returns None stdout — the failing tests/unit/test_smoke.py::test_cli_help_exits_zero. This is live in v0.5.0 on PyPI. (CI's Windows runners use UTF-8, so CI didn't catch it — real users do.)

Fix

  • Repair mojibake across all .py (src, tests, ui, scripts, examples) with ftfy.fix_encoding — restores the intended em dashes / ellipses / curly quotes / section signs. Char-level only; verified no behaviour change.
  • Remove the RUF001/002/003 ignore so the rules resume catching corruption.
  • scripts/extract_abstract.py legitimately emits em/en dashes (LaTeX dash conversion) — annotated with a scoped # noqa: RUF001, the correct surgical exception.
  • Deleted the untracked scratch scripts/inspect_newamp.py.

Verification (CI dependency set — optional extras absent)

  • ruff check . — All checks passed
  • ruff format --check . — clean
  • mypy src/ — Success (also with langchain/mcp uninstalled)
  • tests/unit/test_smoke.py::test_cli_help_exits_zeronow passes
  • full unit suite — 396 passed

Follow-ups (not in this PR)

  • docs/*.md still carry ~800 mojibake sequences (worst: memorywire-paper.md, adapters.md). Not ruff-checked, non-shipping — safe to fix next. The arXiv .tex, README, and CITATION.cff are already clean.
  • v0.5.0 on PyPI still ships the corrupted cli.py — a patch release (v0.5.1) is needed to fix it for installed users.

The prior CI cleanup wrongly ignored RUF001/002/003 as "intentional
typography." They were correctly flagging mojibake — UTF-8 text decoded as
cp1252 and saved back — including two user-facing strings in cli.py that
crash `memorywire --help` on native Windows consoles (the emitted byte
can't be decoded, the capture thread dies). This is live in v0.5.0 on PyPI.

- Repair mojibake across all .py (src, tests, ui, scripts, examples) with
  ftfy.fix_encoding — restores the intended em dashes, ellipses, curly
  quotes, and section signs. Char-level only; no behaviour change.
- Remove the RUF001/002/003 ignore so the rules resume catching corruption.
- extract_abstract.py legitimately emits em/en dashes (LaTeX dash
  conversion) — annotate with a scoped `# noqa: RUF001`, the correct
  surgical exception rather than a blanket ignore.
- Delete the untracked scratch scripts/inspect_newamp.py.

Verified against the CI dependency set (optional extras absent): ruff check
+ ruff format --check + `mypy src/` all clean;
tests/unit/test_smoke.py::test_cli_help_exits_zero now passes; full unit
suite 396 green.

Docs (*.md, ~800 sequences) still carry mojibake — not ruff-checked and
non-shipping — tracked as a follow-up. v0.5.0 on PyPI still ships the
corrupted cli.py; a patch release is needed to fix it for installed users.
@mthamil107
mthamil107 merged commit b4bff07 into main Aug 13, 2026
10 checks passed
@mthamil107
mthamil107 deleted the fix/mojibake-corruption branch August 13, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant