Skip to content

correction: Drop redundant BCH decoding paths - #151

Merged
BenWestgate merged 1 commit into
reviewability-v1from
claude/simplify-correction-v1
Oct 20, 2026
Merged

BenWestgate merged 1 commit into
reviewability-v1from
claude/simplify-correction-v1

Conversation

@BenWestgate

Copy link
Copy Markdown
Owner

This is #150, which merged into bails-v1-pin, carried up to the v1 staging branch as you asked. The cherry-pick applied cleanly with no edits.

Before: correction.py on reviewability-v1 re-checked every BCH correction against the full residue. It also fell back to the linear erasure solver after any failed BCH decode, and carried erasure-product tables that were never built. It was 1,050 lines.

After: it gives the same results in 981 lines. Insertion/deletion correction is untouched.

Why the removed paths can't change a result is explained in #150 and in the commit message. In short:

  • The generator's 8 consecutive roots force the conjugate roots too.
  • An erasure-only solution with 8 or fewer erasures is already found by BCH.
  • The rest was dead code.

Tests on this branch:

  • pytest -q: 907 passed. reviewability-v1 collects the same 907.
  • python -O -m pytest on the four correction test files: 239 passed.
  • ruff check, ruff format --check and mypy src/codex32 are clean.
  • tools/differential_correction.py --verify verified 57 cases, and tools/verify_correction_constants.py passes.

Generated by Claude Code

Remove code from the substitution and erasure decoder that cannot change
a result.

Every BCH correction was re-checked against the full residue. The check
cannot fail. The generator is the product of the distinct minimal
polynomials of the 8 consecutive roots. GF(32) values that clear those
syndromes also clear the conjugate roots, so the generator divides the
corrected word. The linear erasure solver already rejects inconsistent
systems. Delete _corrections_reach_target.

The linear solver ran after a failed BCH decode even with at most 8
erasures. In that case an erasure-only solution leaves the Forney
syndromes zero, so BCH would already have found it. Call the solver only
when the erasures exceed the BCH roots. The worksheet path now makes the
same choice inline, so _error_corrections is gone. Its word-length and
substitution-limit parameters were unused.

The precomputed erasure-product tables were never built. Remove that
plumbing from _locator_poly, _bch_syndrome_corrections, _repair_body and
_FixedCorrector. Also drop the no-op "except TypeError: raise" clauses.

Keep the direct small-locator solve. Replacing it with Berlekamp-Massey
for every call returned identical results but made the bounded indel
search about 15% slower, which could change truncation under the ten-
second deadline.

Validation: full pytest in normal and -O modes; differential_correction
and differential_wallet --verify; verify_correction_constants; ruff
check, ruff format --check and mypy. An offline comparison against the
previous module found identical results for random BCH syndromes,
damaged ms strings with up to 14 errors or erasures, and worksheet
residues with up to 15 erasures.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T20:48:19.733067Z ca2e99c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@BenWestgate BenWestgate left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BenWestgate
BenWestgate merged commit 32e4c4b into reviewability-v1 Oct 20, 2026
23 checks passed
@BenWestgate
BenWestgate deleted the claude/simplify-correction-v1 branch October 20, 2026 09:20
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.

2 participants