Repository navigation
correction: Drop redundant BCH decoding paths - #150
Merged
Merged
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Owner
Author
|
Also send this upstream to the v1 staging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:
correction.pyre-checked every BCH correction against the full residue, fell back to the linear erasure solver after any failed BCH decode, and carried erasure-product tables that were never built. It was 953 lines.After: the same results from 884 lines (cloc 804 → 734). The package size budget goes from 4,986 to 4,921 lines. Insertion/deletion correction is untouched.
The removed paths can't change a result:
_error_corrections(its length and limit parameters were unused) and two no-opexcept TypeError: raiseclauses.How: one commit to
src/codex32/correction.py. Every name thatindel.py, the GUI, the CLI, the tests and the tools import is still there. Swapping_small_locatorfor Berlekamp–Massey was tried and reverted. It gave the same results but made the bounded indel search about 15% slower, which could change truncation under the ten-second deadline.Tests:
pytest -q, both normally and withpython -O: 987 passed, the same as before the change.ruff check,ruff format --checkandmypy src/codex32are clean.tools/differential_correction.py --verify,tools/differential_wallet.py --verifyandtools/verify_correction_constants.pypass.The wallet oracle's pinned
bip32source wasn't reachable here, so the wallet differential ran againstbip32==5.0.0from PyPI. Separately,tools/correction_benchmark.pyalready fails to import on bails-v1-pin because_automatic_targetsis missing.Generated by Claude Code